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
lionsoul2014/jcseg
jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/UriEntry.java
UriEntry.get
public String get(int idx) { if ( idx < 0 || idx >= parts.size() ) { throw new IndexOutOfBoundsException(); } return parts.get(idx); }
java
public String get(int idx) { if ( idx < 0 || idx >= parts.size() ) { throw new IndexOutOfBoundsException(); } return parts.get(idx); }
[ "public", "String", "get", "(", "int", "idx", ")", "{", "if", "(", "idx", "<", "0", "||", "idx", ">=", "parts", ".", "size", "(", ")", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", ")", ";", "}", "return", "parts", ".", "get", "(", ...
the specifiled part of the request uri @param idx
[ "the", "specifiled", "part", "of", "the", "request", "uri" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/UriEntry.java#L109-L116
train
lionsoul2014/jcseg
jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/ContextRouter.java
ContextRouter.getPathEntry
private PathEntry getPathEntry(UriEntry uri) { PathEntry pathEntry = new PathEntry( ContextRouter.MAP_PATH_TYPE, "default"); int length = uri.getLength(); // like /a or / if ( length < 2) return pathEntry; String requestUri = uri.getRequestUri(); String last_str = uri.get( length - 1 ); if ( last_str.equals("*") || last_str.equals("") ) { // StringBuffer buffer = new StringBuffer(); // buffer.append('/'); // // for(int i = 0; i < length - 1; i++) // { // buffer.append(uri.get(i) + "/"); // } // position of last / charactor int lastPosition = requestUri.lastIndexOf('/'); pathEntry.type = ContextRouter.MATCH_PATH_TYPE; pathEntry.key = requestUri.substring(0, lastPosition + 1); // @TODO maybe we should get parameters to pathEntry } else { pathEntry.key = requestUri; } return pathEntry; }
java
private PathEntry getPathEntry(UriEntry uri) { PathEntry pathEntry = new PathEntry( ContextRouter.MAP_PATH_TYPE, "default"); int length = uri.getLength(); // like /a or / if ( length < 2) return pathEntry; String requestUri = uri.getRequestUri(); String last_str = uri.get( length - 1 ); if ( last_str.equals("*") || last_str.equals("") ) { // StringBuffer buffer = new StringBuffer(); // buffer.append('/'); // // for(int i = 0; i < length - 1; i++) // { // buffer.append(uri.get(i) + "/"); // } // position of last / charactor int lastPosition = requestUri.lastIndexOf('/'); pathEntry.type = ContextRouter.MATCH_PATH_TYPE; pathEntry.key = requestUri.substring(0, lastPosition + 1); // @TODO maybe we should get parameters to pathEntry } else { pathEntry.key = requestUri; } return pathEntry; }
[ "private", "PathEntry", "getPathEntry", "(", "UriEntry", "uri", ")", "{", "PathEntry", "pathEntry", "=", "new", "PathEntry", "(", "ContextRouter", ".", "MAP_PATH_TYPE", ",", "\"default\"", ")", ";", "int", "length", "=", "uri", ".", "getLength", "(", ")", ";...
get the final key with specified path paths : return: /a/b : /a/b /a/* : /a/ /a/b/c : /a/b/c /a/b/* : /a/b/ /a/b/ : /a/b/
[ "get", "the", "final", "key", "with", "specified", "path" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-server/src/main/java/org/lionsoul/jcseg/server/core/ContextRouter.java#L59-L93
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java
IStringBuffer.resizeTo
private void resizeTo( int length ) { if ( length <= 0 ) throw new IllegalArgumentException("length <= 0"); if ( length != buff.length ) { int len = ( length > buff.length ) ? buff.length : length; //System.out.println("resize:"+length); char[] obuff = buff; buff = new char[length]; /*for ( int j = 0; j < len; j++ ) { buff[j] = obuff[j]; }*/ System.arraycopy(obuff, 0, buff, 0, len); } }
java
private void resizeTo( int length ) { if ( length <= 0 ) throw new IllegalArgumentException("length <= 0"); if ( length != buff.length ) { int len = ( length > buff.length ) ? buff.length : length; //System.out.println("resize:"+length); char[] obuff = buff; buff = new char[length]; /*for ( int j = 0; j < len; j++ ) { buff[j] = obuff[j]; }*/ System.arraycopy(obuff, 0, buff, 0, len); } }
[ "private", "void", "resizeTo", "(", "int", "length", ")", "{", "if", "(", "length", "<=", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"length <= 0\"", ")", ";", "if", "(", "length", "!=", "buff", ".", "length", ")", "{", "int", "len", ...
resize the buffer this will have to copy the old chars from the old buffer to the new buffer @param length
[ "resize", "the", "buffer", "this", "will", "have", "to", "copy", "the", "old", "chars", "from", "the", "old", "buffer", "to", "the", "new", "buffer" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java#L59-L74
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java
IStringBuffer.append
public IStringBuffer append( String str ) { if ( str == null ) throw new NullPointerException(); //check the necessary to resize the buffer. if ( count + str.length() > buff.length ) { resizeTo( (count + str.length()) * 2 + 1 ); } for ( int j = 0; j < str.length(); j++ ) { buff[count++] = str.charAt(j); } return this; }
java
public IStringBuffer append( String str ) { if ( str == null ) throw new NullPointerException(); //check the necessary to resize the buffer. if ( count + str.length() > buff.length ) { resizeTo( (count + str.length()) * 2 + 1 ); } for ( int j = 0; j < str.length(); j++ ) { buff[count++] = str.charAt(j); } return this; }
[ "public", "IStringBuffer", "append", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "throw", "new", "NullPointerException", "(", ")", ";", "//check the necessary to resize the buffer.", "if", "(", "count", "+", "str", ".", "length", "(", ...
append a string to the buffer @param str string to append to
[ "append", "a", "string", "to", "the", "buffer" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java#L81-L95
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java
IStringBuffer.append
public IStringBuffer append( char[] chars, int start, int length ) { if ( chars == null ) throw new NullPointerException(); if ( start < 0 ) throw new IndexOutOfBoundsException(); if ( length <= 0 ) throw new IndexOutOfBoundsException(); if ( start + length > chars.length ) throw new IndexOutOfBoundsException(); //check the necessary to resize the buffer. if ( count + length > buff.length ) { resizeTo( (count + length) * 2 + 1 ); } for ( int j = 0; j < length; j++ ) { buff[count++] = chars[start+j]; } return this; }
java
public IStringBuffer append( char[] chars, int start, int length ) { if ( chars == null ) throw new NullPointerException(); if ( start < 0 ) throw new IndexOutOfBoundsException(); if ( length <= 0 ) throw new IndexOutOfBoundsException(); if ( start + length > chars.length ) throw new IndexOutOfBoundsException(); //check the necessary to resize the buffer. if ( count + length > buff.length ) { resizeTo( (count + length) * 2 + 1 ); } for ( int j = 0; j < length; j++ ) { buff[count++] = chars[start+j]; } return this; }
[ "public", "IStringBuffer", "append", "(", "char", "[", "]", "chars", ",", "int", "start", ",", "int", "length", ")", "{", "if", "(", "chars", "==", "null", ")", "throw", "new", "NullPointerException", "(", ")", ";", "if", "(", "start", "<", "0", ")",...
append parts of the chars to the buffer @param chars @param start the start index @param length length of chars to append to
[ "append", "parts", "of", "the", "chars", "to", "the", "buffer" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java#L104-L125
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java
IStringBuffer.append
public IStringBuffer append( char[] chars, int start ) { append(chars, start, chars.length - start); return this; }
java
public IStringBuffer append( char[] chars, int start ) { append(chars, start, chars.length - start); return this; }
[ "public", "IStringBuffer", "append", "(", "char", "[", "]", "chars", ",", "int", "start", ")", "{", "append", "(", "chars", ",", "start", ",", "chars", ".", "length", "-", "start", ")", ";", "return", "this", ";", "}" ]
append the rest of the chars to the buffer @param chars @param start the start index @return IStringBuffer
[ "append", "the", "rest", "of", "the", "chars", "to", "the", "buffer" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java#L135-L139
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java
IStringBuffer.append
public IStringBuffer append( char c ) { if ( count == buff.length ) { resizeTo( buff.length * 2 + 1 ); } buff[count++] = c; return this; }
java
public IStringBuffer append( char c ) { if ( count == buff.length ) { resizeTo( buff.length * 2 + 1 ); } buff[count++] = c; return this; }
[ "public", "IStringBuffer", "append", "(", "char", "c", ")", "{", "if", "(", "count", "==", "buff", ".", "length", ")", "{", "resizeTo", "(", "buff", ".", "length", "*", "2", "+", "1", ")", ";", "}", "buff", "[", "count", "++", "]", "=", "c", ";...
append a char to the buffer @param c the char to append to
[ "append", "a", "char", "to", "the", "buffer" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java#L156-L165
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java
IStringBuffer.charAt
public char charAt( int idx ) { if ( idx < 0 ) throw new IndexOutOfBoundsException("idx{"+idx+"} < 0"); if ( idx >= count ) throw new IndexOutOfBoundsException("idx{"+idx+"} >= buffer.length"); return buff[idx]; }
java
public char charAt( int idx ) { if ( idx < 0 ) throw new IndexOutOfBoundsException("idx{"+idx+"} < 0"); if ( idx >= count ) throw new IndexOutOfBoundsException("idx{"+idx+"} >= buffer.length"); return buff[idx]; }
[ "public", "char", "charAt", "(", "int", "idx", ")", "{", "if", "(", "idx", "<", "0", ")", "throw", "new", "IndexOutOfBoundsException", "(", "\"idx{\"", "+", "idx", "+", "\"} < 0\"", ")", ";", "if", "(", "idx", ">=", "count", ")", "throw", "new", "Ind...
get the char at a specified position in the buffer
[ "get", "the", "char", "at", "a", "specified", "position", "in", "the", "buffer" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java#L255-L262
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java
IStringBuffer.deleteCharAt
public IStringBuffer deleteCharAt( int idx ) { if ( idx < 0 ) throw new IndexOutOfBoundsException("idx < 0"); if ( idx >= count ) throw new IndexOutOfBoundsException("idx >= buffer.length"); //here we got a bug for j < count //change over it to count - 1 //thanks for the feedback of xuyijun@gmail.com //@date 2013-08-22 for ( int j = idx; j < count - 1; j++ ) { buff[j] = buff[j+1]; } count--; return this; }
java
public IStringBuffer deleteCharAt( int idx ) { if ( idx < 0 ) throw new IndexOutOfBoundsException("idx < 0"); if ( idx >= count ) throw new IndexOutOfBoundsException("idx >= buffer.length"); //here we got a bug for j < count //change over it to count - 1 //thanks for the feedback of xuyijun@gmail.com //@date 2013-08-22 for ( int j = idx; j < count - 1; j++ ) { buff[j] = buff[j+1]; } count--; return this; }
[ "public", "IStringBuffer", "deleteCharAt", "(", "int", "idx", ")", "{", "if", "(", "idx", "<", "0", ")", "throw", "new", "IndexOutOfBoundsException", "(", "\"idx < 0\"", ")", ";", "if", "(", "idx", ">=", "count", ")", "throw", "new", "IndexOutOfBoundsExcepti...
delete the char at the specified position
[ "delete", "the", "char", "at", "the", "specified", "position" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java#L295-L312
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java
IStringBuffer.set
public void set(int idx, char chr) { if ( idx < 0 ) throw new IndexOutOfBoundsException("idx < 0"); if ( idx >= count ) throw new IndexOutOfBoundsException("idx >= buffer.length"); buff[idx] = chr; }
java
public void set(int idx, char chr) { if ( idx < 0 ) throw new IndexOutOfBoundsException("idx < 0"); if ( idx >= count ) throw new IndexOutOfBoundsException("idx >= buffer.length"); buff[idx] = chr; }
[ "public", "void", "set", "(", "int", "idx", ",", "char", "chr", ")", "{", "if", "(", "idx", "<", "0", ")", "throw", "new", "IndexOutOfBoundsException", "(", "\"idx < 0\"", ")", ";", "if", "(", "idx", ">=", "count", ")", "throw", "new", "IndexOutOfBound...
set the char at the specified index @param idx @param chr
[ "set", "the", "char", "at", "the", "specified", "index" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/util/IStringBuffer.java#L320-L328
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/NLPSeg.java
NLPSeg.getNextTimeMergedWord
protected IWord getNextTimeMergedWord(IWord word, int eIdx) throws IOException { int pIdx = TimeUtil.getDateTimeIndex(word.getEntity(eIdx)); if ( pIdx == TimeUtil.DATETIME_NONE ) { return null; } IWord[] wMask = TimeUtil.createDateTimePool(); TimeUtil.fillDateTimePool(wMask, pIdx, word); IWord dWord = null; int mergedNum = 0; while ( (dWord = super.next()) != null ) { String[] entity = dWord.getEntity(); if ( entity == null ) { eWordPool.push(dWord); break; } if ( ArrayUtil.startsWith("time.a", entity) > -1 ) { if ( TimeUtil.DATETIME_NONE == TimeUtil.fillDateTimePool(wMask, dWord) ) { eWordPool.push(dWord); break; } } else if ( ArrayUtil.startsWith("datetime.hi", entity) > -1 ) { /* * check and merge the date time time part with a style * like 15:45 or 15:45:36 eg... */ TimeUtil.fillTimeToPool(wMask, dWord.getValue()); } else if ( ArrayUtil.startsWith(Entity.E_DATETIME_P, entity) > -1 ) { int tIdx = TimeUtil.fillDateTimePool(wMask, dWord); if ( tIdx == TimeUtil.DATETIME_NONE || wMask[tIdx-1] == null ) { eWordPool.push(dWord); break; } } else { eWordPool.push(dWord); break; } mergedNum++; } if ( mergedNum == 0 ) { return null; } buffer.clear(); for ( int i = 0; i < wMask.length; i++ ) { if ( wMask[i] == null ) { continue; } if ( buffer.length() > 0 && (i+1) < wMask.length ) { buffer.append(' '); } buffer.append(wMask[i].getValue()); } dWord = new Word(buffer.toString(), IWord.T_BASIC_LATIN); dWord.setPosition(word.getPosition()); dWord.setPartSpeech(IWord.TIME_POSPEECH); //check and define the entity buffer.clear().append("datetime."); for ( int i = 0; i < wMask.length; i++ ) { if ( wMask[i] == null ) continue; buffer.append(TimeUtil.getTimeKey(wMask[i])); } dWord.setEntity(new String[]{buffer.toString()}); return dWord; }
java
protected IWord getNextTimeMergedWord(IWord word, int eIdx) throws IOException { int pIdx = TimeUtil.getDateTimeIndex(word.getEntity(eIdx)); if ( pIdx == TimeUtil.DATETIME_NONE ) { return null; } IWord[] wMask = TimeUtil.createDateTimePool(); TimeUtil.fillDateTimePool(wMask, pIdx, word); IWord dWord = null; int mergedNum = 0; while ( (dWord = super.next()) != null ) { String[] entity = dWord.getEntity(); if ( entity == null ) { eWordPool.push(dWord); break; } if ( ArrayUtil.startsWith("time.a", entity) > -1 ) { if ( TimeUtil.DATETIME_NONE == TimeUtil.fillDateTimePool(wMask, dWord) ) { eWordPool.push(dWord); break; } } else if ( ArrayUtil.startsWith("datetime.hi", entity) > -1 ) { /* * check and merge the date time time part with a style * like 15:45 or 15:45:36 eg... */ TimeUtil.fillTimeToPool(wMask, dWord.getValue()); } else if ( ArrayUtil.startsWith(Entity.E_DATETIME_P, entity) > -1 ) { int tIdx = TimeUtil.fillDateTimePool(wMask, dWord); if ( tIdx == TimeUtil.DATETIME_NONE || wMask[tIdx-1] == null ) { eWordPool.push(dWord); break; } } else { eWordPool.push(dWord); break; } mergedNum++; } if ( mergedNum == 0 ) { return null; } buffer.clear(); for ( int i = 0; i < wMask.length; i++ ) { if ( wMask[i] == null ) { continue; } if ( buffer.length() > 0 && (i+1) < wMask.length ) { buffer.append(' '); } buffer.append(wMask[i].getValue()); } dWord = new Word(buffer.toString(), IWord.T_BASIC_LATIN); dWord.setPosition(word.getPosition()); dWord.setPartSpeech(IWord.TIME_POSPEECH); //check and define the entity buffer.clear().append("datetime."); for ( int i = 0; i < wMask.length; i++ ) { if ( wMask[i] == null ) continue; buffer.append(TimeUtil.getTimeKey(wMask[i])); } dWord.setEntity(new String[]{buffer.toString()}); return dWord; }
[ "protected", "IWord", "getNextTimeMergedWord", "(", "IWord", "word", ",", "int", "eIdx", ")", "throws", "IOException", "{", "int", "pIdx", "=", "TimeUtil", ".", "getDateTimeIndex", "(", "word", ".", "getEntity", "(", "eIdx", ")", ")", ";", "if", "(", "pIdx...
get and return the next time merged date-time word @param word @param eIdx @return IWord @throws IOException
[ "get", "and", "return", "the", "next", "time", "merged", "date", "-", "time", "word" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/NLPSeg.java#L242-L319
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/NLPSeg.java
NLPSeg.getNextDatetimeWord
protected IWord getNextDatetimeWord(IWord word, int entityIdx) throws IOException { IWord dWord = super.next(); if ( dWord == null ) { return null; } String[] entity = dWord.getEntity(); if ( entity == null ) { eWordPool.add(dWord); return null; } int eIdx = 0; if ( (eIdx = ArrayUtil.startsWith("datetime.h", entity)) > -1 ) { // do nothing here } else if ( (eIdx = ArrayUtil.startsWith("time.a", entity)) > -1 || (eIdx = ArrayUtil.startsWith(Entity.E_DATETIME_P, entity)) > -1 ) { /* * @Note: added at 2017/04/01 * 1, A word start with time.h or datetime.h could be merged * 2, if the new time merged word could not be merged with the origin word * and we should put the dWord to the first of the eWordPool cuz #getNextTimeMergedWord * may append some IWord to the end of eWordPool */ IWord mWord = getNextTimeMergedWord(dWord, eIdx); if ( mWord == null ) { eWordPool.addFirst(dWord); return null; } String mEntity = mWord.getEntity(0); if ( ! (mEntity.contains(".h") || mEntity.contains(".a")) ) { eWordPool.addFirst(mWord); return null; } eIdx = 0; dWord = mWord; entity = dWord.getEntity(); } else { eWordPool.add(dWord); return null; } buffer.clear().append(word.getValue()).append(' ').append(dWord.getValue()); dWord = new Word(buffer.toString(), IWord.T_BASIC_LATIN); dWord.setPosition(word.getPosition()); dWord.setPartSpeech(IWord.TIME_POSPEECH); //re-define the entity //int sIdx = entity.indexOf('.') + 1; // int sIdx = entity[eIdx].charAt(0) == 't' ? 5 : 9; int sIdx = 9; // datetime buffer.clear().append(word.getEntity(0)).append(entity[eIdx].substring(sIdx)); dWord.addEntity(buffer.toString()); return dWord; }
java
protected IWord getNextDatetimeWord(IWord word, int entityIdx) throws IOException { IWord dWord = super.next(); if ( dWord == null ) { return null; } String[] entity = dWord.getEntity(); if ( entity == null ) { eWordPool.add(dWord); return null; } int eIdx = 0; if ( (eIdx = ArrayUtil.startsWith("datetime.h", entity)) > -1 ) { // do nothing here } else if ( (eIdx = ArrayUtil.startsWith("time.a", entity)) > -1 || (eIdx = ArrayUtil.startsWith(Entity.E_DATETIME_P, entity)) > -1 ) { /* * @Note: added at 2017/04/01 * 1, A word start with time.h or datetime.h could be merged * 2, if the new time merged word could not be merged with the origin word * and we should put the dWord to the first of the eWordPool cuz #getNextTimeMergedWord * may append some IWord to the end of eWordPool */ IWord mWord = getNextTimeMergedWord(dWord, eIdx); if ( mWord == null ) { eWordPool.addFirst(dWord); return null; } String mEntity = mWord.getEntity(0); if ( ! (mEntity.contains(".h") || mEntity.contains(".a")) ) { eWordPool.addFirst(mWord); return null; } eIdx = 0; dWord = mWord; entity = dWord.getEntity(); } else { eWordPool.add(dWord); return null; } buffer.clear().append(word.getValue()).append(' ').append(dWord.getValue()); dWord = new Word(buffer.toString(), IWord.T_BASIC_LATIN); dWord.setPosition(word.getPosition()); dWord.setPartSpeech(IWord.TIME_POSPEECH); //re-define the entity //int sIdx = entity.indexOf('.') + 1; // int sIdx = entity[eIdx].charAt(0) == 't' ? 5 : 9; int sIdx = 9; // datetime buffer.clear().append(word.getEntity(0)).append(entity[eIdx].substring(sIdx)); dWord.addEntity(buffer.toString()); return dWord; }
[ "protected", "IWord", "getNextDatetimeWord", "(", "IWord", "word", ",", "int", "entityIdx", ")", "throws", "IOException", "{", "IWord", "dWord", "=", "super", ".", "next", "(", ")", ";", "if", "(", "dWord", "==", "null", ")", "{", "return", "null", ";", ...
get and return the next date-time word @param word @param entityIdx @return IWord @throws IOException
[ "get", "and", "return", "the", "next", "date", "-", "time", "word" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/NLPSeg.java#L329-L388
train
lionsoul2014/jcseg
jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/NLPSeg.java
NLPSeg.getNumericUnitComposedWord
private IWord getNumericUnitComposedWord(String numeric, IWord unitWord) { IStringBuffer sb = new IStringBuffer(); sb.clear().append(numeric).append(unitWord.getValue()); IWord wd = new Word(sb.toString(), IWord.T_CJK_WORD); String[] entity = unitWord.getEntity(); int eIdx = ArrayUtil.startsWith(Entity.E_TIME_P, entity); if ( eIdx > -1 ) { sb.clear().append(entity[eIdx].replace("time.", "datetime.")); } else { sb.clear().append(Entity.E_NUC_PREFIX ).append(unitWord.getEntity(0)); } wd.setEntity(new String[] {sb.toString()}); wd.setPartSpeech(IWord.QUANTIFIER); sb.clear();sb = null; return wd; }
java
private IWord getNumericUnitComposedWord(String numeric, IWord unitWord) { IStringBuffer sb = new IStringBuffer(); sb.clear().append(numeric).append(unitWord.getValue()); IWord wd = new Word(sb.toString(), IWord.T_CJK_WORD); String[] entity = unitWord.getEntity(); int eIdx = ArrayUtil.startsWith(Entity.E_TIME_P, entity); if ( eIdx > -1 ) { sb.clear().append(entity[eIdx].replace("time.", "datetime.")); } else { sb.clear().append(Entity.E_NUC_PREFIX ).append(unitWord.getEntity(0)); } wd.setEntity(new String[] {sb.toString()}); wd.setPartSpeech(IWord.QUANTIFIER); sb.clear();sb = null; return wd; }
[ "private", "IWord", "getNumericUnitComposedWord", "(", "String", "numeric", ",", "IWord", "unitWord", ")", "{", "IStringBuffer", "sb", "=", "new", "IStringBuffer", "(", ")", ";", "sb", ".", "clear", "(", ")", ".", "append", "(", "numeric", ")", ".", "appen...
internal method to define the composed entity for numeric and unit word composed word @param numeric @param unitWord @return IWord
[ "internal", "method", "to", "define", "the", "composed", "entity", "for", "numeric", "and", "unit", "word", "composed", "word" ]
7c8a912e3bbcaf4f8de701180b9c24e2e444a94b
https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/NLPSeg.java#L398-L417
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/IssueManager.java
IssueManager.getIssuesBySummary
public List<Issue> getIssuesBySummary(String projectKey, String summaryField) throws RedmineException { if ((projectKey != null) && (projectKey.length() > 0)) { return transport.getObjectsList(Issue.class, new BasicNameValuePair("subject", summaryField), new BasicNameValuePair("project_id", projectKey)); } else { return transport.getObjectsList(Issue.class, new BasicNameValuePair("subject", summaryField)); } }
java
public List<Issue> getIssuesBySummary(String projectKey, String summaryField) throws RedmineException { if ((projectKey != null) && (projectKey.length() > 0)) { return transport.getObjectsList(Issue.class, new BasicNameValuePair("subject", summaryField), new BasicNameValuePair("project_id", projectKey)); } else { return transport.getObjectsList(Issue.class, new BasicNameValuePair("subject", summaryField)); } }
[ "public", "List", "<", "Issue", ">", "getIssuesBySummary", "(", "String", "projectKey", ",", "String", "summaryField", ")", "throws", "RedmineException", "{", "if", "(", "(", "projectKey", "!=", "null", ")", "&&", "(", "projectKey", ".", "length", "(", ")", ...
There could be several issues with the same summary, so the method returns List. @return empty list if not issues with this summary field exist, never NULL @throws RedmineAuthenticationException invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments. @throws NotFoundException @throws RedmineException
[ "There", "could", "be", "several", "issues", "with", "the", "same", "summary", "so", "the", "method", "returns", "List", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/IssueManager.java#L57-L66
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/IssueManager.java
IssueManager.getSavedQueries
public List<SavedQuery> getSavedQueries(String projectKey) throws RedmineException { Set<NameValuePair> params = new HashSet<>(); if ((projectKey != null) && (projectKey.length() > 0)) { params.add(new BasicNameValuePair("project_id", projectKey)); } return transport.getObjectsList(SavedQuery.class, params); }
java
public List<SavedQuery> getSavedQueries(String projectKey) throws RedmineException { Set<NameValuePair> params = new HashSet<>(); if ((projectKey != null) && (projectKey.length() > 0)) { params.add(new BasicNameValuePair("project_id", projectKey)); } return transport.getObjectsList(SavedQuery.class, params); }
[ "public", "List", "<", "SavedQuery", ">", "getSavedQueries", "(", "String", "projectKey", ")", "throws", "RedmineException", "{", "Set", "<", "NameValuePair", ">", "params", "=", "new", "HashSet", "<>", "(", ")", ";", "if", "(", "(", "projectKey", "!=", "n...
Get "saved queries" for the given project available to the current user. <p>This REST API feature was added in Redmine 1.3.0. See http://www.redmine.org/issues/5737</p>
[ "Get", "saved", "queries", "for", "the", "given", "project", "available", "to", "the", "current", "user", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/IssueManager.java#L326-L334
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/json/JsonOutput.java
JsonOutput.addIfNotNull
public static <T> void addIfNotNull(JSONWriter writer, String field, T value, JsonObjectWriter<T> objWriter) throws JSONException { if (value == null) return; writer.key(field); writer.object(); objWriter.write(writer, value); writer.endObject(); }
java
public static <T> void addIfNotNull(JSONWriter writer, String field, T value, JsonObjectWriter<T> objWriter) throws JSONException { if (value == null) return; writer.key(field); writer.object(); objWriter.write(writer, value); writer.endObject(); }
[ "public", "static", "<", "T", ">", "void", "addIfNotNull", "(", "JSONWriter", "writer", ",", "String", "field", ",", "T", "value", ",", "JsonObjectWriter", "<", "T", ">", "objWriter", ")", "throws", "JSONException", "{", "if", "(", "value", "==", "null", ...
Adds an object if object is not null. @param writer object writer. @param field field writer. @param value value writer. @param objWriter object value writer. @throws JSONException if io error occurs.
[ "Adds", "an", "object", "if", "object", "is", "not", "null", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/json/JsonOutput.java#L152-L160
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/json/JsonOutput.java
JsonOutput.addScalarArray
public static <T> void addScalarArray(JSONWriter writer, String field, Collection<T> items, JsonObjectWriter<T> objWriter) throws JSONException { writer.key(field); writer.array(); for (T item : items) { objWriter.write(writer, item); } writer.endArray(); }
java
public static <T> void addScalarArray(JSONWriter writer, String field, Collection<T> items, JsonObjectWriter<T> objWriter) throws JSONException { writer.key(field); writer.array(); for (T item : items) { objWriter.write(writer, item); } writer.endArray(); }
[ "public", "static", "<", "T", ">", "void", "addScalarArray", "(", "JSONWriter", "writer", ",", "String", "field", ",", "Collection", "<", "T", ">", "items", ",", "JsonObjectWriter", "<", "T", ">", "objWriter", ")", "throws", "JSONException", "{", "writer", ...
Adds a list of scalar values. @param writer used writer. @param field field to write. @param items used items. @param objWriter single value writer.
[ "Adds", "a", "list", "of", "scalar", "values", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/json/JsonOutput.java#L174-L183
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/URIConfigurator.java
URIConfigurator.addAPIKey
public URI addAPIKey(String uri) { try { final URIBuilder builder = new URIBuilder(uri); if (apiAccessKey != null) { builder.setParameter("key", apiAccessKey); } return builder.build(); } catch (URISyntaxException e) { throw new RedmineInternalError(e); } }
java
public URI addAPIKey(String uri) { try { final URIBuilder builder = new URIBuilder(uri); if (apiAccessKey != null) { builder.setParameter("key", apiAccessKey); } return builder.build(); } catch (URISyntaxException e) { throw new RedmineInternalError(e); } }
[ "public", "URI", "addAPIKey", "(", "String", "uri", ")", "{", "try", "{", "final", "URIBuilder", "builder", "=", "new", "URIBuilder", "(", "uri", ")", ";", "if", "(", "apiAccessKey", "!=", "null", ")", "{", "builder", ".", "setParameter", "(", "\"key\"",...
Adds API key to URI, if the key is specified @param uri Original URI string @return URI with API key added
[ "Adds", "API", "key", "to", "URI", "if", "the", "key", "is", "specified" ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/URIConfigurator.java#L176-L186
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/comm/betterssl/BetterSSLFactory.java
BetterSSLFactory.createSocketFactory
public static SSLSocketFactory createSocketFactory(Collection<KeyStore> extraStores) throws KeyStoreException, KeyManagementException { final Collection<X509TrustManager> managers = new ArrayList<>(); for (KeyStore ks : extraStores) { addX509Managers(managers, ks); } /* Add default manager. */ addX509Managers(managers, null); final TrustManager tm = new CompositeTrustManager(managers); try { final SSLContext ctx = SSLContext.getInstance("SSL"); ctx.init(null, new TrustManager[] {tm}, null); return new SSLSocketFactory(ctx); } catch (NoSuchAlgorithmException e) { throw new Error("No SSL protocols supported :(", e); } }
java
public static SSLSocketFactory createSocketFactory(Collection<KeyStore> extraStores) throws KeyStoreException, KeyManagementException { final Collection<X509TrustManager> managers = new ArrayList<>(); for (KeyStore ks : extraStores) { addX509Managers(managers, ks); } /* Add default manager. */ addX509Managers(managers, null); final TrustManager tm = new CompositeTrustManager(managers); try { final SSLContext ctx = SSLContext.getInstance("SSL"); ctx.init(null, new TrustManager[] {tm}, null); return new SSLSocketFactory(ctx); } catch (NoSuchAlgorithmException e) { throw new Error("No SSL protocols supported :(", e); } }
[ "public", "static", "SSLSocketFactory", "createSocketFactory", "(", "Collection", "<", "KeyStore", ">", "extraStores", ")", "throws", "KeyStoreException", ",", "KeyManagementException", "{", "final", "Collection", "<", "X509TrustManager", ">", "managers", "=", "new", ...
Creates a new SSL socket factory which supports both system-installed keys and all additional keys in the provided keystores. @param extraStores extra keystores containing root certificate authorities. @return Socket factory supporting authorization for both system (default) keystores and all the extraStores. @throws KeyStoreException if key store have problems. @throws KeyManagementException if new SSL context could not be initialized.
[ "Creates", "a", "new", "SSL", "socket", "factory", "which", "supports", "both", "system", "-", "installed", "keys", "and", "all", "additional", "keys", "in", "the", "provided", "keystores", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/comm/betterssl/BetterSSLFactory.java#L37-L53
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/comm/betterssl/BetterSSLFactory.java
BetterSSLFactory.addX509Managers
private static void addX509Managers(final Collection<X509TrustManager> managers, KeyStore ks) throws KeyStoreException, Error { try { final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); for (TrustManager tm : tmf.getTrustManagers()) { if (tm instanceof X509TrustManager) { managers.add((X509TrustManager) tm); } } } catch (NoSuchAlgorithmException e) { throw new Error("Default trust manager algorithm is not supported!", e); } }
java
private static void addX509Managers(final Collection<X509TrustManager> managers, KeyStore ks) throws KeyStoreException, Error { try { final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); for (TrustManager tm : tmf.getTrustManagers()) { if (tm instanceof X509TrustManager) { managers.add((X509TrustManager) tm); } } } catch (NoSuchAlgorithmException e) { throw new Error("Default trust manager algorithm is not supported!", e); } }
[ "private", "static", "void", "addX509Managers", "(", "final", "Collection", "<", "X509TrustManager", ">", "managers", ",", "KeyStore", "ks", ")", "throws", "KeyStoreException", ",", "Error", "{", "try", "{", "final", "TrustManagerFactory", "tmf", "=", "TrustManage...
Adds X509 keystore-backed trust manager into the list of managers. @param managers list of the managers to add to. @param ks key store with target keys. @throws KeyStoreException if key store could not be accessed.
[ "Adds", "X509", "keystore", "-", "backed", "trust", "manager", "into", "the", "list", "of", "managers", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/comm/betterssl/BetterSSLFactory.java#L61-L74
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/Transport.java
Transport.addObject
public <T> T addObject(T object, NameValuePair... params) throws RedmineException { final EntityConfig<T> config = getConfig(object.getClass()); if (config.writer == null) { throw new RuntimeException("can't create object: writer is not implemented or is not registered in RedmineJSONBuilder for object " + object); } URI uri = getURIConfigurator().getObjectsURI(object.getClass(), params); HttpPost httpPost = new HttpPost(uri); String body = RedmineJSONBuilder.toSimpleJSON(config.singleObjectName, object, config.writer); setEntity(httpPost, body); String response = send(httpPost); logger.debug(response); return parseResponse(response, config.singleObjectName, config.parser); }
java
public <T> T addObject(T object, NameValuePair... params) throws RedmineException { final EntityConfig<T> config = getConfig(object.getClass()); if (config.writer == null) { throw new RuntimeException("can't create object: writer is not implemented or is not registered in RedmineJSONBuilder for object " + object); } URI uri = getURIConfigurator().getObjectsURI(object.getClass(), params); HttpPost httpPost = new HttpPost(uri); String body = RedmineJSONBuilder.toSimpleJSON(config.singleObjectName, object, config.writer); setEntity(httpPost, body); String response = send(httpPost); logger.debug(response); return parseResponse(response, config.singleObjectName, config.parser); }
[ "public", "<", "T", ">", "T", "addObject", "(", "T", "object", ",", "NameValuePair", "...", "params", ")", "throws", "RedmineException", "{", "final", "EntityConfig", "<", "T", ">", "config", "=", "getConfig", "(", "object", ".", "getClass", "(", ")", ")...
Performs an "add object" request. @param object object to use. @param params name params. @return object to use. @throws RedmineException if something goes wrong.
[ "Performs", "an", "add", "object", "request", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/Transport.java#L220-L233
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/Transport.java
Transport.deleteChildId
public <T> void deleteChildId(Class<?> parentClass, String parentId, T object, Integer value) throws RedmineException { URI uri = getURIConfigurator().getChildIdURI(parentClass, parentId, object.getClass(), value); HttpDelete httpDelete = new HttpDelete(uri); String response = send(httpDelete); logger.debug(response); }
java
public <T> void deleteChildId(Class<?> parentClass, String parentId, T object, Integer value) throws RedmineException { URI uri = getURIConfigurator().getChildIdURI(parentClass, parentId, object.getClass(), value); HttpDelete httpDelete = new HttpDelete(uri); String response = send(httpDelete); logger.debug(response); }
[ "public", "<", "T", ">", "void", "deleteChildId", "(", "Class", "<", "?", ">", "parentClass", ",", "String", "parentId", ",", "T", "object", ",", "Integer", "value", ")", "throws", "RedmineException", "{", "URI", "uri", "=", "getURIConfigurator", "(", ")",...
Performs "delete child Id" request. @param parentClass parent object id. @param object object to use. @param value child object id. @throws RedmineException if something goes wrong.
[ "Performs", "delete", "child", "Id", "request", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/Transport.java#L311-L316
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/Transport.java
Transport.deleteObject
public <T extends Identifiable> void deleteObject(Class<T> classs, String id) throws RedmineException { final URI uri = getURIConfigurator().getObjectURI(classs, id); final HttpDelete http = new HttpDelete(uri); send(http); }
java
public <T extends Identifiable> void deleteObject(Class<T> classs, String id) throws RedmineException { final URI uri = getURIConfigurator().getObjectURI(classs, id); final HttpDelete http = new HttpDelete(uri); send(http); }
[ "public", "<", "T", "extends", "Identifiable", ">", "void", "deleteObject", "(", "Class", "<", "T", ">", "classs", ",", "String", "id", ")", "throws", "RedmineException", "{", "final", "URI", "uri", "=", "getURIConfigurator", "(", ")", ".", "getObjectURI", ...
Deletes an object. @param classs object class. @param id object id. @throws RedmineException if something goes wrong.
[ "Deletes", "an", "object", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/Transport.java#L328-L333
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/Transport.java
Transport.download
public <R> R download(String uri, ContentHandler<BasicHttpResponse, R> handler) throws RedmineException { final URI requestUri = configurator.addAPIKey(uri); final HttpGet request = new HttpGet(requestUri); if (onBehalfOfUser != null) { request.addHeader("X-Redmine-Switch-User", onBehalfOfUser); } return errorCheckingCommunicator.sendRequest(request, handler); }
java
public <R> R download(String uri, ContentHandler<BasicHttpResponse, R> handler) throws RedmineException { final URI requestUri = configurator.addAPIKey(uri); final HttpGet request = new HttpGet(requestUri); if (onBehalfOfUser != null) { request.addHeader("X-Redmine-Switch-User", onBehalfOfUser); } return errorCheckingCommunicator.sendRequest(request, handler); }
[ "public", "<", "R", ">", "R", "download", "(", "String", "uri", ",", "ContentHandler", "<", "BasicHttpResponse", ",", "R", ">", "handler", ")", "throws", "RedmineException", "{", "final", "URI", "requestUri", "=", "configurator", ".", "addAPIKey", "(", "uri"...
Downloads redmine content. @param uri target uri. @param handler content handler. @return handler result. @throws RedmineException if something goes wrong.
[ "Downloads", "redmine", "content", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/Transport.java#L370-L379
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/Transport.java
Transport.getChildEntry
public <T> T getChildEntry(Class<?> parentClass, String parentId, Class<T> classs, String childId, NameValuePair... params) throws RedmineException { final EntityConfig<T> config = getConfig(classs); final URI uri = getURIConfigurator().getChildIdURI(parentClass, parentId, classs, childId, params); HttpGet http = new HttpGet(uri); String response = send(http); return parseResponse(response, config.singleObjectName, config.parser); }
java
public <T> T getChildEntry(Class<?> parentClass, String parentId, Class<T> classs, String childId, NameValuePair... params) throws RedmineException { final EntityConfig<T> config = getConfig(classs); final URI uri = getURIConfigurator().getChildIdURI(parentClass, parentId, classs, childId, params); HttpGet http = new HttpGet(uri); String response = send(http); return parseResponse(response, config.singleObjectName, config.parser); }
[ "public", "<", "T", ">", "T", "getChildEntry", "(", "Class", "<", "?", ">", "parentClass", ",", "String", "parentId", ",", "Class", "<", "T", ">", "classs", ",", "String", "childId", ",", "NameValuePair", "...", "params", ")", "throws", "RedmineException",...
Delivers a single child entry by its identifier.
[ "Delivers", "a", "single", "child", "entry", "by", "its", "identifier", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/Transport.java#L546-L554
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/bean/Project.java
Project.addTrackers
public Project addTrackers(Collection<Tracker> trackers) { if (!storage.isPropertySet(TRACKERS)) //checks because trackers storage is not created for new projects storage.set(TRACKERS, new HashSet<>()); storage.get(TRACKERS).addAll(trackers); return this; }
java
public Project addTrackers(Collection<Tracker> trackers) { if (!storage.isPropertySet(TRACKERS)) //checks because trackers storage is not created for new projects storage.set(TRACKERS, new HashSet<>()); storage.get(TRACKERS).addAll(trackers); return this; }
[ "public", "Project", "addTrackers", "(", "Collection", "<", "Tracker", ">", "trackers", ")", "{", "if", "(", "!", "storage", ".", "isPropertySet", "(", "TRACKERS", ")", ")", "//checks because trackers storage is not created for new projects", "storage", ".", "set", ...
Adds the specified trackers to this project. If this project is created or updated on the redmine server, each tracker id must be a valid tracker on the server.
[ "Adds", "the", "specified", "trackers", "to", "this", "project", ".", "If", "this", "project", "is", "created", "or", "updated", "on", "the", "redmine", "server", "each", "tracker", "id", "must", "be", "a", "valid", "tracker", "on", "the", "server", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/bean/Project.java#L132-L137
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/RedmineManagerFactory.java
RedmineManagerFactory.createUnauthenticated
public static RedmineManager createUnauthenticated(String uri, HttpClient httpClient) { return createWithUserAuth(uri, null, null, httpClient); }
java
public static RedmineManager createUnauthenticated(String uri, HttpClient httpClient) { return createWithUserAuth(uri, null, null, httpClient); }
[ "public", "static", "RedmineManager", "createUnauthenticated", "(", "String", "uri", ",", "HttpClient", "httpClient", ")", "{", "return", "createWithUserAuth", "(", "uri", ",", "null", ",", "null", ",", "httpClient", ")", ";", "}" ]
Creates a non-authenticating redmine manager. @param uri redmine manager URI. @param httpClient you can provide your own pre-configured HttpClient if you want to control connection pooling, manage connections eviction, closing, etc.
[ "Creates", "a", "non", "-", "authenticating", "redmine", "manager", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/RedmineManagerFactory.java#L75-L78
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/RedmineManagerFactory.java
RedmineManagerFactory.createWithUserAuth
public static RedmineManager createWithUserAuth(String uri, String login, String password) { return createWithUserAuth(uri, login, password, createDefaultHttpClient(uri)); }
java
public static RedmineManager createWithUserAuth(String uri, String login, String password) { return createWithUserAuth(uri, login, password, createDefaultHttpClient(uri)); }
[ "public", "static", "RedmineManager", "createWithUserAuth", "(", "String", "uri", ",", "String", "login", ",", "String", "password", ")", "{", "return", "createWithUserAuth", "(", "uri", ",", "login", ",", "password", ",", "createDefaultHttpClient", "(", "uri", ...
Creates a new RedmineManager with user-based authentication. @param uri redmine manager URI. @param login user's name. @param password user's password.
[ "Creates", "a", "new", "RedmineManager", "with", "user", "-", "based", "authentication", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/RedmineManagerFactory.java#L125-L129
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/RedmineManagerFactory.java
RedmineManagerFactory.createWithUserAuth
public static RedmineManager createWithUserAuth(String uri, String login, String password, HttpClient httpClient) { final Transport transport = new Transport( new URIConfigurator(uri, null), httpClient); transport.setCredentials(login, password); return new RedmineManager(transport); }
java
public static RedmineManager createWithUserAuth(String uri, String login, String password, HttpClient httpClient) { final Transport transport = new Transport( new URIConfigurator(uri, null), httpClient); transport.setCredentials(login, password); return new RedmineManager(transport); }
[ "public", "static", "RedmineManager", "createWithUserAuth", "(", "String", "uri", ",", "String", "login", ",", "String", "password", ",", "HttpClient", "httpClient", ")", "{", "final", "Transport", "transport", "=", "new", "Transport", "(", "new", "URIConfigurator...
Creates a new redmine managen with user-based authentication. @param uri redmine manager URI. @param login user's name. @param password user's password. @param httpClient you can provide your own pre-configured HttpClient if you want to control connection pooling, manage connections eviction, closing, etc.
[ "Creates", "a", "new", "redmine", "managen", "with", "user", "-", "based", "authentication", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/RedmineManagerFactory.java#L140-L146
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/bean/WikiPageDetail.java
WikiPageDetail.update
public void update() throws RedmineException { String urlSafeTitle = getUrlSafeString(getTitle()); transport.updateChildEntry(Project.class, getProjectKey(), this, urlSafeTitle); }
java
public void update() throws RedmineException { String urlSafeTitle = getUrlSafeString(getTitle()); transport.updateChildEntry(Project.class, getProjectKey(), this, urlSafeTitle); }
[ "public", "void", "update", "(", ")", "throws", "RedmineException", "{", "String", "urlSafeTitle", "=", "getUrlSafeString", "(", "getTitle", "(", ")", ")", ";", "transport", ".", "updateChildEntry", "(", "Project", ".", "class", ",", "getProjectKey", "(", ")",...
projectKey must be set before calling this. Version must be set to the latest version of the document.
[ "projectKey", "must", "be", "set", "before", "calling", "this", ".", "Version", "must", "be", "set", "to", "the", "latest", "version", "of", "the", "document", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/bean/WikiPageDetail.java#L140-L143
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/comm/TransportDecoder.java
TransportDecoder.decodeStream
private InputStream decodeStream(String encoding, InputStream initialStream) throws IOException { if (encoding == null) return initialStream; if ("gzip".equals(encoding)) return new GZIPInputStream(initialStream); if ("deflate".equals(encoding)) return new InflaterInputStream(initialStream); throw new IOException("Unsupported transport encoding " + encoding); }
java
private InputStream decodeStream(String encoding, InputStream initialStream) throws IOException { if (encoding == null) return initialStream; if ("gzip".equals(encoding)) return new GZIPInputStream(initialStream); if ("deflate".equals(encoding)) return new InflaterInputStream(initialStream); throw new IOException("Unsupported transport encoding " + encoding); }
[ "private", "InputStream", "decodeStream", "(", "String", "encoding", ",", "InputStream", "initialStream", ")", "throws", "IOException", "{", "if", "(", "encoding", "==", "null", ")", "return", "initialStream", ";", "if", "(", "\"gzip\"", ".", "equals", "(", "e...
Decodes a transport stream. @param encoding stream encoding. @param initialStream initial stream. @return decoding stream. @throws IOException
[ "Decodes", "a", "transport", "stream", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/comm/TransportDecoder.java#L48-L57
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/bean/PropertyStorageUtil.java
PropertyStorageUtil.updateCollections
public static void updateCollections(PropertyStorage storage, Transport transport) { storage.getProperties().forEach(e -> { if (Collection.class.isAssignableFrom(e.getKey().getType())) { // found a collection in properties ((Collection) e.getValue()).forEach(i -> { if (i instanceof FluentStyle) { ((FluentStyle) i).setTransport(transport); } }); } }); }
java
public static void updateCollections(PropertyStorage storage, Transport transport) { storage.getProperties().forEach(e -> { if (Collection.class.isAssignableFrom(e.getKey().getType())) { // found a collection in properties ((Collection) e.getValue()).forEach(i -> { if (i instanceof FluentStyle) { ((FluentStyle) i).setTransport(transport); } }); } }); }
[ "public", "static", "void", "updateCollections", "(", "PropertyStorage", "storage", ",", "Transport", "transport", ")", "{", "storage", ".", "getProperties", "(", ")", ".", "forEach", "(", "e", "->", "{", "if", "(", "Collection", ".", "class", ".", "isAssign...
go over all properties in the storage and set `transport` on FluentStyle instances inside collections, if any. only process one level, without recursion - to avoid potential cycles and such.
[ "go", "over", "all", "properties", "in", "the", "storage", "and", "set", "transport", "on", "FluentStyle", "instances", "inside", "collections", "if", "any", ".", "only", "process", "one", "level", "without", "recursion", "-", "to", "avoid", "potential", "cycl...
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/bean/PropertyStorageUtil.java#L12-L25
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/RedmineJSONBuilder.java
RedmineJSONBuilder.writeProject
public static void writeProject(JSONWriter writer, Project project) throws IllegalArgumentException, JSONException { /* Validate project */ if (project.getName() == null) throw new IllegalArgumentException( "Project name must be set to create a new project"); if (project.getIdentifier() == null) throw new IllegalArgumentException( "Project identifier must be set to create a new project"); writeProject(project, writer); }
java
public static void writeProject(JSONWriter writer, Project project) throws IllegalArgumentException, JSONException { /* Validate project */ if (project.getName() == null) throw new IllegalArgumentException( "Project name must be set to create a new project"); if (project.getIdentifier() == null) throw new IllegalArgumentException( "Project identifier must be set to create a new project"); writeProject(project, writer); }
[ "public", "static", "void", "writeProject", "(", "JSONWriter", "writer", ",", "Project", "project", ")", "throws", "IllegalArgumentException", ",", "JSONException", "{", "/* Validate project */", "if", "(", "project", ".", "getName", "(", ")", "==", "null", ")", ...
Writes a "create project" request. @param writer project writer. @param project project to create. @throws IllegalArgumentException if some project fields are not configured. @throws JSONException if IO error occurs.
[ "Writes", "a", "create", "project", "request", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/RedmineJSONBuilder.java#L53-L64
train
taskadapter/redmine-java-api
src/main/java/com/taskadapter/redmineapi/internal/RedmineJSONBuilder.java
RedmineJSONBuilder.toSimpleJSON
public static <T> String toSimpleJSON(String tag, T object, JsonObjectWriter<T> writer) throws RedmineInternalError { final StringWriter swriter = new StringWriter(); final JSONWriter jsWriter = new JSONWriter(swriter); try { jsWriter.object(); jsWriter.key(tag); jsWriter.object(); writer.write(jsWriter, object); jsWriter.endObject(); jsWriter.endObject(); } catch (JSONException e) { throw new RedmineInternalError("Unexpected JSONException", e); } return swriter.toString(); }
java
public static <T> String toSimpleJSON(String tag, T object, JsonObjectWriter<T> writer) throws RedmineInternalError { final StringWriter swriter = new StringWriter(); final JSONWriter jsWriter = new JSONWriter(swriter); try { jsWriter.object(); jsWriter.key(tag); jsWriter.object(); writer.write(jsWriter, object); jsWriter.endObject(); jsWriter.endObject(); } catch (JSONException e) { throw new RedmineInternalError("Unexpected JSONException", e); } return swriter.toString(); }
[ "public", "static", "<", "T", ">", "String", "toSimpleJSON", "(", "String", "tag", ",", "T", "object", ",", "JsonObjectWriter", "<", "T", ">", "writer", ")", "throws", "RedmineInternalError", "{", "final", "StringWriter", "swriter", "=", "new", "StringWriter",...
Converts object to a "simple" json. @param tag object tag. @param object object to convert. @param writer object writer. @return object String representation. @throws RedmineInternalError if conversion fails.
[ "Converts", "object", "to", "a", "simple", "json", "." ]
0bb65f27ee806ec3bd4007e1641f3e996261a04e
https://github.com/taskadapter/redmine-java-api/blob/0bb65f27ee806ec3bd4007e1641f3e996261a04e/src/main/java/com/taskadapter/redmineapi/internal/RedmineJSONBuilder.java#L118-L134
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/routing/Routers.java
Routers.getRouter
public static Router getRouter(Class<? extends Router> routerType) { return routers.computeIfAbsent(routerType, Routers::create); }
java
public static Router getRouter(Class<? extends Router> routerType) { return routers.computeIfAbsent(routerType, Routers::create); }
[ "public", "static", "Router", "getRouter", "(", "Class", "<", "?", "extends", "Router", ">", "routerType", ")", "{", "return", "routers", ".", "computeIfAbsent", "(", "routerType", ",", "Routers", "::", "create", ")", ";", "}" ]
Get router instance by a given router class. The class should have a default constructor. Otherwise no router can be created @param routerType the type of the Router. @return instance of the Router.
[ "Get", "router", "instance", "by", "a", "given", "router", "class", ".", "The", "class", "should", "have", "a", "default", "constructor", ".", "Otherwise", "no", "router", "can", "be", "created" ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/routing/Routers.java#L23-L25
train
scalecube/scalecube-services
services-gateway-websocket/src/main/java/io/scalecube/services/gateway/ws/WebsocketSession.java
WebsocketSession.send
public Mono<Void> send(GatewayMessage response) { return Mono.defer( () -> outbound .sendObject(Mono.just(response).map(codec::encode).map(TextWebSocketFrame::new)) .then() .doOnSuccessOrError((avoid, th) -> logSend(response, th))); }
java
public Mono<Void> send(GatewayMessage response) { return Mono.defer( () -> outbound .sendObject(Mono.just(response).map(codec::encode).map(TextWebSocketFrame::new)) .then() .doOnSuccessOrError((avoid, th) -> logSend(response, th))); }
[ "public", "Mono", "<", "Void", ">", "send", "(", "GatewayMessage", "response", ")", "{", "return", "Mono", ".", "defer", "(", "(", ")", "->", "outbound", ".", "sendObject", "(", "Mono", ".", "just", "(", "response", ")", ".", "map", "(", "codec", "::...
Method to send normal response. @param response response @return mono void
[ "Method", "to", "send", "normal", "response", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-websocket/src/main/java/io/scalecube/services/gateway/ws/WebsocketSession.java#L82-L89
train
scalecube/scalecube-services
services-gateway-websocket/src/main/java/io/scalecube/services/gateway/ws/WebsocketSession.java
WebsocketSession.onClose
public Mono<Void> onClose(Disposable disposable) { return Mono.create( sink -> inbound.withConnection( connection -> connection .onDispose(disposable) .onTerminate() .subscribe(sink::success, sink::error, sink::success))); }
java
public Mono<Void> onClose(Disposable disposable) { return Mono.create( sink -> inbound.withConnection( connection -> connection .onDispose(disposable) .onTerminate() .subscribe(sink::success, sink::error, sink::success))); }
[ "public", "Mono", "<", "Void", ">", "onClose", "(", "Disposable", "disposable", ")", "{", "return", "Mono", ".", "create", "(", "sink", "->", "inbound", ".", "withConnection", "(", "connection", "->", "connection", ".", "onDispose", "(", "disposable", ")", ...
Lambda setter for reacting on channel close occurrence. @param disposable function to run when disposable would take place
[ "Lambda", "setter", "for", "reacting", "on", "channel", "close", "occurrence", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-websocket/src/main/java/io/scalecube/services/gateway/ws/WebsocketSession.java#L116-L125
train
scalecube/scalecube-services
services-gateway-websocket/src/main/java/io/scalecube/services/gateway/ws/WebsocketSession.java
WebsocketSession.dispose
public boolean dispose(Long streamId) { boolean result = false; if (streamId != null) { Disposable disposable = subscriptions.remove(streamId); result = disposable != null; if (result) { LOGGER.debug("Dispose subscription by sid={}, session={}", streamId, id); disposable.dispose(); } } return result; }
java
public boolean dispose(Long streamId) { boolean result = false; if (streamId != null) { Disposable disposable = subscriptions.remove(streamId); result = disposable != null; if (result) { LOGGER.debug("Dispose subscription by sid={}, session={}", streamId, id); disposable.dispose(); } } return result; }
[ "public", "boolean", "dispose", "(", "Long", "streamId", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "streamId", "!=", "null", ")", "{", "Disposable", "disposable", "=", "subscriptions", ".", "remove", "(", "streamId", ")", ";", "result", ...
Disposing stored subscription by given stream id. @param streamId stream id @return true of subscription was disposed
[ "Disposing", "stored", "subscription", "by", "given", "stream", "id", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-websocket/src/main/java/io/scalecube/services/gateway/ws/WebsocketSession.java#L133-L144
train
scalecube/scalecube-services
services-discovery/src/main/java/io/scalecube/services/discovery/ScalecubeServiceDiscovery.java
ScalecubeServiceDiscovery.start
@Override public Mono<ServiceDiscovery> start() { return Mono.defer( () -> { Map<String, String> metadata = endpoint != null ? Collections.singletonMap( endpoint.id(), ClusterMetadataCodec.encodeMetadata(endpoint)) : Collections.emptyMap(); ClusterConfig clusterConfig = copyFrom(this.clusterConfig).addMetadata(metadata).build(); ScalecubeServiceDiscovery serviceDiscovery = new ScalecubeServiceDiscovery(this, clusterConfig); return Cluster.join(clusterConfig) .doOnSuccess(cluster -> serviceDiscovery.cluster = cluster) .thenReturn(serviceDiscovery); }); }
java
@Override public Mono<ServiceDiscovery> start() { return Mono.defer( () -> { Map<String, String> metadata = endpoint != null ? Collections.singletonMap( endpoint.id(), ClusterMetadataCodec.encodeMetadata(endpoint)) : Collections.emptyMap(); ClusterConfig clusterConfig = copyFrom(this.clusterConfig).addMetadata(metadata).build(); ScalecubeServiceDiscovery serviceDiscovery = new ScalecubeServiceDiscovery(this, clusterConfig); return Cluster.join(clusterConfig) .doOnSuccess(cluster -> serviceDiscovery.cluster = cluster) .thenReturn(serviceDiscovery); }); }
[ "@", "Override", "public", "Mono", "<", "ServiceDiscovery", ">", "start", "(", ")", "{", "return", "Mono", ".", "defer", "(", "(", ")", "->", "{", "Map", "<", "String", ",", "String", ">", "metadata", "=", "endpoint", "!=", "null", "?", "Collections", ...
Starts scalecube service discoevery. Joins a cluster with local services as metadata. @return mono result
[ "Starts", "scalecube", "service", "discoevery", ".", "Joins", "a", "cluster", "with", "local", "services", "as", "metadata", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-discovery/src/main/java/io/scalecube/services/discovery/ScalecubeServiceDiscovery.java#L94-L112
train
scalecube/scalecube-services
services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/Reflect.java
Reflect.parameterizedReturnType
private static Class<?> parameterizedReturnType(Method method) { Type type = method.getGenericReturnType(); if (type instanceof ParameterizedType) { try { return Class.forName( (((ParameterizedType) type).getActualTypeArguments()[0]).getTypeName()); } catch (ClassNotFoundException e) { return Object.class; } } else { return Object.class; } }
java
private static Class<?> parameterizedReturnType(Method method) { Type type = method.getGenericReturnType(); if (type instanceof ParameterizedType) { try { return Class.forName( (((ParameterizedType) type).getActualTypeArguments()[0]).getTypeName()); } catch (ClassNotFoundException e) { return Object.class; } } else { return Object.class; } }
[ "private", "static", "Class", "<", "?", ">", "parameterizedReturnType", "(", "Method", "method", ")", "{", "Type", "type", "=", "method", ".", "getGenericReturnType", "(", ")", ";", "if", "(", "type", "instanceof", "ParameterizedType", ")", "{", "try", "{", ...
extract parameterized return value of a method. @param method to extract type from. @return the generic type of the return value or object.
[ "extract", "parameterized", "return", "value", "of", "a", "method", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/Reflect.java#L73-L85
train
scalecube/scalecube-services
services-benchmarks/src/main/java/io/scalecube/services/benchmarks/LatencyHelper.java
LatencyHelper.calculate
public void calculate(ServiceMessage message) { // client to service eval( message.header(SERVICE_RECV_TIME), message.header(CLIENT_SEND_TIME), (v1, v2) -> clientToServiceTimer.update(v1 - v2, TimeUnit.MILLISECONDS)); // service to client eval( message.header(CLIENT_RECV_TIME), message.header(SERVICE_SEND_TIME), (v1, v2) -> serviceToClientTimer.update(v1 - v2, TimeUnit.MILLISECONDS)); }
java
public void calculate(ServiceMessage message) { // client to service eval( message.header(SERVICE_RECV_TIME), message.header(CLIENT_SEND_TIME), (v1, v2) -> clientToServiceTimer.update(v1 - v2, TimeUnit.MILLISECONDS)); // service to client eval( message.header(CLIENT_RECV_TIME), message.header(SERVICE_SEND_TIME), (v1, v2) -> serviceToClientTimer.update(v1 - v2, TimeUnit.MILLISECONDS)); }
[ "public", "void", "calculate", "(", "ServiceMessage", "message", ")", "{", "// client to service", "eval", "(", "message", ".", "header", "(", "SERVICE_RECV_TIME", ")", ",", "message", ".", "header", "(", "CLIENT_SEND_TIME", ")", ",", "(", "v1", ",", "v2", "...
Calculates latencies by the headers into received message. @param message client message
[ "Calculates", "latencies", "by", "the", "headers", "into", "received", "message", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-benchmarks/src/main/java/io/scalecube/services/benchmarks/LatencyHelper.java#L36-L48
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java
ServiceMessage.from
public static Builder from(ServiceMessage message) { return ServiceMessage.builder().data(message.data()).headers(message.headers()); }
java
public static Builder from(ServiceMessage message) { return ServiceMessage.builder().data(message.data()).headers(message.headers()); }
[ "public", "static", "Builder", "from", "(", "ServiceMessage", "message", ")", "{", "return", "ServiceMessage", ".", "builder", "(", ")", ".", "data", "(", "message", ".", "data", "(", ")", ")", ".", "headers", "(", "message", ".", "headers", "(", ")", ...
Instantiates new message with the same data and headers as at given message. @param message the message to be copied @return a new message, with the same data and headers
[ "Instantiates", "new", "message", "with", "the", "same", "data", "and", "headers", "as", "at", "given", "message", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java#L50-L52
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java
ServiceMessage.error
public static ServiceMessage error(int errorType, int errorCode, String errorMessage) { return ServiceMessage.builder() .qualifier(Qualifier.asError(errorType)) .data(new ErrorData(errorCode, errorMessage)) .build(); }
java
public static ServiceMessage error(int errorType, int errorCode, String errorMessage) { return ServiceMessage.builder() .qualifier(Qualifier.asError(errorType)) .data(new ErrorData(errorCode, errorMessage)) .build(); }
[ "public", "static", "ServiceMessage", "error", "(", "int", "errorType", ",", "int", "errorCode", ",", "String", "errorMessage", ")", "{", "return", "ServiceMessage", ".", "builder", "(", ")", ".", "qualifier", "(", "Qualifier", ".", "asError", "(", "errorType"...
Instantiates new message with error qualifier for given error type and specified error code and message. @param errorType the error type to be used in message qualifier. @param errorCode the error code. @param errorMessage the error message. @return builder.
[ "Instantiates", "new", "message", "with", "error", "qualifier", "for", "given", "error", "type", "and", "specified", "error", "code", "and", "message", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java#L63-L68
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java
ServiceMessage.setHeaders
void setHeaders(Map<String, String> headers) { this.headers = Collections.unmodifiableMap(new HashMap<>(headers)); }
java
void setHeaders(Map<String, String> headers) { this.headers = Collections.unmodifiableMap(new HashMap<>(headers)); }
[ "void", "setHeaders", "(", "Map", "<", "String", ",", "String", ">", "headers", ")", "{", "this", ".", "headers", "=", "Collections", ".", "unmodifiableMap", "(", "new", "HashMap", "<>", "(", "headers", ")", ")", ";", "}" ]
Sets headers for deserialization purpose. @param headers headers to set
[ "Sets", "headers", "for", "deserialization", "purpose", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java#L93-L95
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java
ServiceMessage.header
public String header(String name) { Objects.requireNonNull(name); return headers.get(name); }
java
public String header(String name) { Objects.requireNonNull(name); return headers.get(name); }
[ "public", "String", "header", "(", "String", "name", ")", "{", "Objects", ".", "requireNonNull", "(", "name", ")", ";", "return", "headers", ".", "get", "(", "name", ")", ";", "}" ]
Returns header value by given header name. @param name header name @return the message header by given header name
[ "Returns", "header", "value", "by", "given", "header", "name", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java#L112-L115
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java
ServiceMessage.isError
public boolean isError() { String qualifier = qualifier(); return qualifier != null && qualifier.contains(Qualifier.ERROR_NAMESPACE); }
java
public boolean isError() { String qualifier = qualifier(); return qualifier != null && qualifier.contains(Qualifier.ERROR_NAMESPACE); }
[ "public", "boolean", "isError", "(", ")", "{", "String", "qualifier", "=", "qualifier", "(", ")", ";", "return", "qualifier", "!=", "null", "&&", "qualifier", ".", "contains", "(", "Qualifier", ".", "ERROR_NAMESPACE", ")", ";", "}" ]
Describes whether the message is an error. @return <code>true</code> if error, otherwise <code>false</code>.
[ "Describes", "whether", "the", "message", "is", "an", "error", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java#L176-L179
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java
ServiceMessage.errorType
public int errorType() { if (!isError()) { throw new IllegalStateException("Message is not an error"); } try { return Integer.parseInt(Qualifier.getQualifierAction(qualifier())); } catch (NumberFormatException e) { throw new IllegalStateException("Error type must be a number"); } }
java
public int errorType() { if (!isError()) { throw new IllegalStateException("Message is not an error"); } try { return Integer.parseInt(Qualifier.getQualifierAction(qualifier())); } catch (NumberFormatException e) { throw new IllegalStateException("Error type must be a number"); } }
[ "public", "int", "errorType", "(", ")", "{", "if", "(", "!", "isError", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Message is not an error\"", ")", ";", "}", "try", "{", "return", "Integer", ".", "parseInt", "(", "Qualifier", ".",...
Returns error type. Error type is an identifier of a group of errors. @return error type.
[ "Returns", "error", "type", ".", "Error", "type", "is", "an", "identifier", "of", "a", "group", "of", "errors", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/ServiceMessage.java#L186-L196
train
scalecube/scalecube-services
services-discovery/src/main/java/io/scalecube/services/discovery/ClusterAddresses.java
ClusterAddresses.toAddress
public static io.scalecube.transport.Address toAddress( io.scalecube.services.transport.api.Address address) { return io.scalecube.transport.Address.create(address.host(), address.port()); }
java
public static io.scalecube.transport.Address toAddress( io.scalecube.services.transport.api.Address address) { return io.scalecube.transport.Address.create(address.host(), address.port()); }
[ "public", "static", "io", ".", "scalecube", ".", "transport", ".", "Address", "toAddress", "(", "io", ".", "scalecube", ".", "services", ".", "transport", ".", "api", ".", "Address", "address", ")", "{", "return", "io", ".", "scalecube", ".", "transport", ...
Converts one address to another. @param address scalecube services address @return scalecube cluster address
[ "Converts", "one", "address", "to", "another", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-discovery/src/main/java/io/scalecube/services/discovery/ClusterAddresses.java#L18-L21
train
scalecube/scalecube-services
services-discovery/src/main/java/io/scalecube/services/discovery/ClusterAddresses.java
ClusterAddresses.toAddresses
public static io.scalecube.transport.Address[] toAddresses(Address[] addresses) { return Arrays.stream(addresses) .map(ClusterAddresses::toAddress) .toArray(io.scalecube.transport.Address[]::new); }
java
public static io.scalecube.transport.Address[] toAddresses(Address[] addresses) { return Arrays.stream(addresses) .map(ClusterAddresses::toAddress) .toArray(io.scalecube.transport.Address[]::new); }
[ "public", "static", "io", ".", "scalecube", ".", "transport", ".", "Address", "[", "]", "toAddresses", "(", "Address", "[", "]", "addresses", ")", "{", "return", "Arrays", ".", "stream", "(", "addresses", ")", ".", "map", "(", "ClusterAddresses", "::", "...
Converts one address array to another address array. @param addresses scalecube services addresses @return scalecube cluster addresses
[ "Converts", "one", "address", "array", "to", "another", "address", "array", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-discovery/src/main/java/io/scalecube/services/discovery/ClusterAddresses.java#L29-L33
train
scalecube/scalecube-services
services-gateway-common/src/main/java/io/scalecube/services/gateway/GatewayTemplate.java
GatewayTemplate.prepareHttpServer
protected final HttpServer prepareHttpServer( LoopResources loopResources, int port, GatewayMetrics metrics) { return HttpServer.create() .tcpConfiguration( tcpServer -> { if (loopResources != null) { tcpServer = tcpServer.runOn(loopResources); } if (metrics != null) { tcpServer = tcpServer.doOnConnection( connection -> { metrics.incConnection(); connection.onDispose(metrics::decConnection); }); } return tcpServer.addressSupplier(() -> new InetSocketAddress(port)); }); }
java
protected final HttpServer prepareHttpServer( LoopResources loopResources, int port, GatewayMetrics metrics) { return HttpServer.create() .tcpConfiguration( tcpServer -> { if (loopResources != null) { tcpServer = tcpServer.runOn(loopResources); } if (metrics != null) { tcpServer = tcpServer.doOnConnection( connection -> { metrics.incConnection(); connection.onDispose(metrics::decConnection); }); } return tcpServer.addressSupplier(() -> new InetSocketAddress(port)); }); }
[ "protected", "final", "HttpServer", "prepareHttpServer", "(", "LoopResources", "loopResources", ",", "int", "port", ",", "GatewayMetrics", "metrics", ")", "{", "return", "HttpServer", ".", "create", "(", ")", ".", "tcpConfiguration", "(", "tcpServer", "->", "{", ...
Builds generic http server with given parameters. @param loopResources loop resources @param port listen port @param metrics gateway metrics @return http server
[ "Builds", "generic", "http", "server", "with", "given", "parameters", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-common/src/main/java/io/scalecube/services/gateway/GatewayTemplate.java#L37-L55
train
scalecube/scalecube-services
services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/rsocket/RSocketClientCodec.java
RSocketClientCodec.encodeAndTransform
private <T> T encodeAndTransform( ClientMessage message, BiFunction<ByteBuf, ByteBuf, T> transformer) throws MessageCodecException { ByteBuf dataBuffer = Unpooled.EMPTY_BUFFER; ByteBuf headersBuffer = Unpooled.EMPTY_BUFFER; if (message.hasData(ByteBuf.class)) { dataBuffer = message.data(); } else if (message.hasData()) { dataBuffer = ByteBufAllocator.DEFAULT.buffer(); try { dataCodec.encode(new ByteBufOutputStream(dataBuffer), message.data()); } catch (Throwable ex) { ReferenceCountUtil.safestRelease(dataBuffer); LOGGER.error("Failed to encode data on: {}, cause: {}", message, ex); throw new MessageCodecException( "Failed to encode data on message q=" + message.qualifier(), ex); } } if (!message.headers().isEmpty()) { headersBuffer = ByteBufAllocator.DEFAULT.buffer(); try { headersCodec.encode(new ByteBufOutputStream(headersBuffer), message.headers()); } catch (Throwable ex) { ReferenceCountUtil.safestRelease(headersBuffer); ReferenceCountUtil.safestRelease(dataBuffer); // release data as well LOGGER.error("Failed to encode headers on: {}, cause: {}", message, ex); throw new MessageCodecException( "Failed to encode headers on message q=" + message.qualifier(), ex); } } return transformer.apply(dataBuffer, headersBuffer); }
java
private <T> T encodeAndTransform( ClientMessage message, BiFunction<ByteBuf, ByteBuf, T> transformer) throws MessageCodecException { ByteBuf dataBuffer = Unpooled.EMPTY_BUFFER; ByteBuf headersBuffer = Unpooled.EMPTY_BUFFER; if (message.hasData(ByteBuf.class)) { dataBuffer = message.data(); } else if (message.hasData()) { dataBuffer = ByteBufAllocator.DEFAULT.buffer(); try { dataCodec.encode(new ByteBufOutputStream(dataBuffer), message.data()); } catch (Throwable ex) { ReferenceCountUtil.safestRelease(dataBuffer); LOGGER.error("Failed to encode data on: {}, cause: {}", message, ex); throw new MessageCodecException( "Failed to encode data on message q=" + message.qualifier(), ex); } } if (!message.headers().isEmpty()) { headersBuffer = ByteBufAllocator.DEFAULT.buffer(); try { headersCodec.encode(new ByteBufOutputStream(headersBuffer), message.headers()); } catch (Throwable ex) { ReferenceCountUtil.safestRelease(headersBuffer); ReferenceCountUtil.safestRelease(dataBuffer); // release data as well LOGGER.error("Failed to encode headers on: {}, cause: {}", message, ex); throw new MessageCodecException( "Failed to encode headers on message q=" + message.qualifier(), ex); } } return transformer.apply(dataBuffer, headersBuffer); }
[ "private", "<", "T", ">", "T", "encodeAndTransform", "(", "ClientMessage", "message", ",", "BiFunction", "<", "ByteBuf", ",", "ByteBuf", ",", "T", ">", "transformer", ")", "throws", "MessageCodecException", "{", "ByteBuf", "dataBuffer", "=", "Unpooled", ".", "...
Encoder function. @param message client message. @param transformer bi function transformer from two headers and data buffers to client specified object of type T @param <T> client specified type which could be constructed out of headers and data bufs. @return T object @throws MessageCodecException in case if encoding fails
[ "Encoder", "function", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/rsocket/RSocketClientCodec.java#L91-L125
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/transport/api/Address.java
Address.from
public static Address from(String hostAndPort) { String[] split = hostAndPort.split(":"); if (split.length != 2) { throw new IllegalArgumentException(); } String host = split[0]; int port = Integer.parseInt(split[1]); return new Address(host, port); }
java
public static Address from(String hostAndPort) { String[] split = hostAndPort.split(":"); if (split.length != 2) { throw new IllegalArgumentException(); } String host = split[0]; int port = Integer.parseInt(split[1]); return new Address(host, port); }
[ "public", "static", "Address", "from", "(", "String", "hostAndPort", ")", "{", "String", "[", "]", "split", "=", "hostAndPort", ".", "split", "(", "\":\"", ")", ";", "if", "(", "split", ".", "length", "!=", "2", ")", "{", "throw", "new", "IllegalArgume...
Create address. @param hostAndPort host:port @return address
[ "Create", "address", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/transport/api/Address.java#L38-L46
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/Qualifier.java
Qualifier.asString
public static String asString(String namespace, String action) { return DELIMITER + namespace + DELIMITER + action; }
java
public static String asString(String namespace, String action) { return DELIMITER + namespace + DELIMITER + action; }
[ "public", "static", "String", "asString", "(", "String", "namespace", ",", "String", "action", ")", "{", "return", "DELIMITER", "+", "namespace", "+", "DELIMITER", "+", "action", ";", "}" ]
Builds qualifier string out of given namespace and action. @param namespace qualifier namespace. @param action qualifier action. @return constructed qualifier.
[ "Builds", "qualifier", "string", "out", "of", "given", "namespace", "and", "action", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/Qualifier.java#L27-L29
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/Qualifier.java
Qualifier.getQualifierNamespace
public static String getQualifierNamespace(String qualifierAsString) { int pos = qualifierAsString.indexOf(DELIMITER, 1); if (pos == -1) { throw new IllegalArgumentException("Wrong qualifier format: '" + qualifierAsString + "'"); } return qualifierAsString.substring(1, pos); }
java
public static String getQualifierNamespace(String qualifierAsString) { int pos = qualifierAsString.indexOf(DELIMITER, 1); if (pos == -1) { throw new IllegalArgumentException("Wrong qualifier format: '" + qualifierAsString + "'"); } return qualifierAsString.substring(1, pos); }
[ "public", "static", "String", "getQualifierNamespace", "(", "String", "qualifierAsString", ")", "{", "int", "pos", "=", "qualifierAsString", ".", "indexOf", "(", "DELIMITER", ",", "1", ")", ";", "if", "(", "pos", "==", "-", "1", ")", "{", "throw", "new", ...
Extracts qualifier namespace part from given qualifier string. @param qualifierAsString qualifier string. @return qualifier namespace.
[ "Extracts", "qualifier", "namespace", "part", "from", "given", "qualifier", "string", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/Qualifier.java#L37-L43
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/api/Qualifier.java
Qualifier.getQualifierAction
public static String getQualifierAction(String qualifierAsString) { int pos = qualifierAsString.lastIndexOf(DELIMITER); if (pos == -1) { throw new IllegalArgumentException("Wrong qualifier format: '" + qualifierAsString + "'"); } return qualifierAsString.substring(pos + 1); }
java
public static String getQualifierAction(String qualifierAsString) { int pos = qualifierAsString.lastIndexOf(DELIMITER); if (pos == -1) { throw new IllegalArgumentException("Wrong qualifier format: '" + qualifierAsString + "'"); } return qualifierAsString.substring(pos + 1); }
[ "public", "static", "String", "getQualifierAction", "(", "String", "qualifierAsString", ")", "{", "int", "pos", "=", "qualifierAsString", ".", "lastIndexOf", "(", "DELIMITER", ")", ";", "if", "(", "pos", "==", "-", "1", ")", "{", "throw", "new", "IllegalArgu...
Extracts qualifier action part from given qualifier string. @param qualifierAsString qualifier string. @return qualifier action.
[ "Extracts", "qualifier", "action", "part", "from", "given", "qualifier", "string", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/api/Qualifier.java#L51-L57
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java
Market.add
public void add(long instrument, long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) { return; } OrderBook book = books.get(instrument); if (book == null) { return; } Order order = new Order(book, side, price, size); boolean bbo = book.add(side, price, size); orders.put(orderId, order); listener.update(book, bbo); }
java
public void add(long instrument, long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) { return; } OrderBook book = books.get(instrument); if (book == null) { return; } Order order = new Order(book, side, price, size); boolean bbo = book.add(side, price, size); orders.put(orderId, order); listener.update(book, bbo); }
[ "public", "void", "add", "(", "long", "instrument", ",", "long", "orderId", ",", "Side", "side", ",", "long", "price", ",", "long", "size", ")", "{", "if", "(", "orders", ".", "containsKey", "(", "orderId", ")", ")", "{", "return", ";", "}", "OrderBo...
Add an order to an order book. <p>An update event is triggered. <p>If the order book for the instrument is closed or the order identifier is known, do nothing. @param instrument the instrument @param orderId the order identifier @param side the side @param price the price @param size the size
[ "Add", "an", "order", "to", "an", "order", "book", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java#L61-L78
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java
Market.modify
public void modify(long orderId, long size) { Order order = orders.get(orderId); if (order == null) { return; } OrderBook book = order.getOrderBook(); long newSize = Math.max(0, size); boolean bbo = book.update(order.getSide(), order.getPrice(), newSize - order.getRemainingQuantity()); if (newSize == 0) { orders.remove(orderId); } else { order.setRemainingQuantity(newSize); } listener.update(book, bbo); }
java
public void modify(long orderId, long size) { Order order = orders.get(orderId); if (order == null) { return; } OrderBook book = order.getOrderBook(); long newSize = Math.max(0, size); boolean bbo = book.update(order.getSide(), order.getPrice(), newSize - order.getRemainingQuantity()); if (newSize == 0) { orders.remove(orderId); } else { order.setRemainingQuantity(newSize); } listener.update(book, bbo); }
[ "public", "void", "modify", "(", "long", "orderId", ",", "long", "size", ")", "{", "Order", "order", "=", "orders", ".", "get", "(", "orderId", ")", ";", "if", "(", "order", "==", "null", ")", "{", "return", ";", "}", "OrderBook", "book", "=", "ord...
Modify an order in an order book. The order will retain its time priority. If the new size is zero, the order is deleted from the order book. <p>An update event is triggered. <p>If the order identifier is unknown, do nothing. @param orderId the order identifier @param size the new size
[ "Modify", "an", "order", "in", "an", "order", "book", ".", "The", "order", "will", "retain", "its", "time", "priority", ".", "If", "the", "new", "size", "is", "zero", "the", "order", "is", "deleted", "from", "the", "order", "book", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java#L91-L111
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java
Market.execute
public long execute(long orderId, long quantity, long price) { Order order = orders.get(orderId); if (order == null) { return 0; } return execute(orderId, order, quantity, price); }
java
public long execute(long orderId, long quantity, long price) { Order order = orders.get(orderId); if (order == null) { return 0; } return execute(orderId, order, quantity, price); }
[ "public", "long", "execute", "(", "long", "orderId", ",", "long", "quantity", ",", "long", "price", ")", "{", "Order", "order", "=", "orders", ".", "get", "(", "orderId", ")", ";", "if", "(", "order", "==", "null", ")", "{", "return", "0", ";", "}"...
Execute a quantity of an order in an order book. If the remaining quantity reaches zero, the order is deleted from the order book. <p>A Trade event and an update event are triggered. <p>If the order identifier is unknown, do nothing. @param orderId the order identifier @param quantity the executed quantity @param price the execution price @return the remaining quantity
[ "Execute", "a", "quantity", "of", "an", "order", "in", "an", "order", "book", ".", "If", "the", "remaining", "quantity", "reaches", "zero", "the", "order", "is", "deleted", "from", "the", "order", "book", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java#L147-L154
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java
Market.cancel
public long cancel(long orderId, long quantity) { Order order = orders.get(orderId); if (order == null) { return 0; } OrderBook book = order.getOrderBook(); long remainingQuantity = order.getRemainingQuantity(); long canceledQuantity = Math.min(quantity, remainingQuantity); boolean bbo = book.update(order.getSide(), order.getPrice(), -canceledQuantity); if (canceledQuantity == remainingQuantity) { orders.remove(orderId); } else { order.reduce(canceledQuantity); } listener.update(book, bbo); return remainingQuantity - canceledQuantity; }
java
public long cancel(long orderId, long quantity) { Order order = orders.get(orderId); if (order == null) { return 0; } OrderBook book = order.getOrderBook(); long remainingQuantity = order.getRemainingQuantity(); long canceledQuantity = Math.min(quantity, remainingQuantity); boolean bbo = book.update(order.getSide(), order.getPrice(), -canceledQuantity); if (canceledQuantity == remainingQuantity) { orders.remove(orderId); } else { order.reduce(canceledQuantity); } listener.update(book, bbo); return remainingQuantity - canceledQuantity; }
[ "public", "long", "cancel", "(", "long", "orderId", ",", "long", "quantity", ")", "{", "Order", "order", "=", "orders", ".", "get", "(", "orderId", ")", ";", "if", "(", "order", "==", "null", ")", "{", "return", "0", ";", "}", "OrderBook", "book", ...
Cancel a quantity of an order in an order book. If the remaining quantity reaches zero, the order is deleted from the order book. <p>An update event is triggered. <p>If the order identifier is unknown, do nothing. @param orderId the order identifier @param quantity the canceled quantity @return the remaining quantity
[ "Cancel", "a", "quantity", "of", "an", "order", "in", "an", "order", "book", ".", "If", "the", "remaining", "quantity", "reaches", "zero", "the", "order", "is", "deleted", "from", "the", "order", "book", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java#L192-L215
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java
Market.delete
public void delete(long orderId) { Order order = orders.get(orderId); if (order == null) { return; } OrderBook book = order.getOrderBook(); boolean bbo = book.update(order.getSide(), order.getPrice(), -order.getRemainingQuantity()); orders.remove(orderId); listener.update(book, bbo); }
java
public void delete(long orderId) { Order order = orders.get(orderId); if (order == null) { return; } OrderBook book = order.getOrderBook(); boolean bbo = book.update(order.getSide(), order.getPrice(), -order.getRemainingQuantity()); orders.remove(orderId); listener.update(book, bbo); }
[ "public", "void", "delete", "(", "long", "orderId", ")", "{", "Order", "order", "=", "orders", ".", "get", "(", "orderId", ")", ";", "if", "(", "order", "==", "null", ")", "{", "return", ";", "}", "OrderBook", "book", "=", "order", ".", "getOrderBook...
Delete an order from an order book. <p>An update event is triggered. <p>If the order identifier is unknown, do nothing. @param orderId the order identifier
[ "Delete", "an", "order", "from", "an", "order", "book", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/Market.java#L226-L239
train
scalecube/scalecube-services
services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/Client.java
Client.rsocket
public static Client rsocket(ClientSettings clientSettings) { RSocketClientCodec clientCodec = new RSocketClientCodec( HeadersCodec.getInstance(clientSettings.contentType()), DataCodec.getInstance(clientSettings.contentType())); RSocketClientTransport clientTransport = new RSocketClientTransport(clientSettings, clientCodec, clientSettings.loopResources()); return new Client(clientTransport, clientCodec, clientSettings.errorMapper()); }
java
public static Client rsocket(ClientSettings clientSettings) { RSocketClientCodec clientCodec = new RSocketClientCodec( HeadersCodec.getInstance(clientSettings.contentType()), DataCodec.getInstance(clientSettings.contentType())); RSocketClientTransport clientTransport = new RSocketClientTransport(clientSettings, clientCodec, clientSettings.loopResources()); return new Client(clientTransport, clientCodec, clientSettings.errorMapper()); }
[ "public", "static", "Client", "rsocket", "(", "ClientSettings", "clientSettings", ")", "{", "RSocketClientCodec", "clientCodec", "=", "new", "RSocketClientCodec", "(", "HeadersCodec", ".", "getInstance", "(", "clientSettings", ".", "contentType", "(", ")", ")", ",",...
Client on rsocket client transport. @param clientSettings client settings @return client
[ "Client", "on", "rsocket", "client", "transport", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/Client.java#L58-L68
train
scalecube/scalecube-services
services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/Client.java
Client.websocket
public static Client websocket(ClientSettings clientSettings) { WebsocketClientCodec clientCodec = new WebsocketClientCodec(DataCodec.getInstance(clientSettings.contentType())); WebsocketClientTransport clientTransport = new WebsocketClientTransport(clientSettings, clientCodec, clientSettings.loopResources()); return new Client(clientTransport, clientCodec, clientSettings.errorMapper()); }
java
public static Client websocket(ClientSettings clientSettings) { WebsocketClientCodec clientCodec = new WebsocketClientCodec(DataCodec.getInstance(clientSettings.contentType())); WebsocketClientTransport clientTransport = new WebsocketClientTransport(clientSettings, clientCodec, clientSettings.loopResources()); return new Client(clientTransport, clientCodec, clientSettings.errorMapper()); }
[ "public", "static", "Client", "websocket", "(", "ClientSettings", "clientSettings", ")", "{", "WebsocketClientCodec", "clientCodec", "=", "new", "WebsocketClientCodec", "(", "DataCodec", ".", "getInstance", "(", "clientSettings", ".", "contentType", "(", ")", ")", "...
Client on websocket client transport. @param clientSettings client settings @return client
[ "Client", "on", "websocket", "client", "transport", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/Client.java#L76-L84
train
scalecube/scalecube-services
services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/Client.java
Client.http
public static Client http(ClientSettings clientSettings) { HttpClientCodec clientCodec = new HttpClientCodec(DataCodec.getInstance(clientSettings.contentType())); ClientTransport clientTransport = new HttpClientTransport(clientSettings, clientCodec, clientSettings.loopResources()); return new Client(clientTransport, clientCodec, clientSettings.errorMapper()); }
java
public static Client http(ClientSettings clientSettings) { HttpClientCodec clientCodec = new HttpClientCodec(DataCodec.getInstance(clientSettings.contentType())); ClientTransport clientTransport = new HttpClientTransport(clientSettings, clientCodec, clientSettings.loopResources()); return new Client(clientTransport, clientCodec, clientSettings.errorMapper()); }
[ "public", "static", "Client", "http", "(", "ClientSettings", "clientSettings", ")", "{", "HttpClientCodec", "clientCodec", "=", "new", "HttpClientCodec", "(", "DataCodec", ".", "getInstance", "(", "clientSettings", ".", "contentType", "(", ")", ")", ")", ";", "C...
Client on http client transport. @param clientSettings client settings @return client
[ "Client", "on", "http", "client", "transport", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/Client.java#L92-L100
train
scalecube/scalecube-services
services-examples-runner/src/main/java/io/scalecube/services/examples/ExamplesRunner.java
ExamplesRunner.main
public static void main(String[] args) throws Exception { ConfigRegistry configRegistry = ConfigBootstrap.configRegistry(); Config config = configRegistry .objectProperty("io.scalecube.services.examples", Config.class) .value() .orElseThrow(() -> new IllegalStateException("Couldn't load config")); LOGGER.info(DECORATOR); LOGGER.info("Starting Examples services on {}", config); LOGGER.info(DECORATOR); int numOfThreads = Optional.ofNullable(config.numOfThreads()) .orElse(Runtime.getRuntime().availableProcessors()); LOGGER.info("Number of worker threads: " + numOfThreads); Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, config)) .transport(opts -> serviceTransport(numOfThreads, opts, config)) .services(new BenchmarkServiceImpl(), new GreetingServiceImpl()) .startAwait(); Thread.currentThread().join(); }
java
public static void main(String[] args) throws Exception { ConfigRegistry configRegistry = ConfigBootstrap.configRegistry(); Config config = configRegistry .objectProperty("io.scalecube.services.examples", Config.class) .value() .orElseThrow(() -> new IllegalStateException("Couldn't load config")); LOGGER.info(DECORATOR); LOGGER.info("Starting Examples services on {}", config); LOGGER.info(DECORATOR); int numOfThreads = Optional.ofNullable(config.numOfThreads()) .orElse(Runtime.getRuntime().availableProcessors()); LOGGER.info("Number of worker threads: " + numOfThreads); Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, config)) .transport(opts -> serviceTransport(numOfThreads, opts, config)) .services(new BenchmarkServiceImpl(), new GreetingServiceImpl()) .startAwait(); Thread.currentThread().join(); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "ConfigRegistry", "configRegistry", "=", "ConfigBootstrap", ".", "configRegistry", "(", ")", ";", "Config", "config", "=", "configRegistry", ".", "objectPropert...
Main method of gateway runner. @param args program arguments @throws Exception exception thrown
[ "Main", "method", "of", "gateway", "runner", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples-runner/src/main/java/io/scalecube/services/examples/ExamplesRunner.java#L38-L63
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/metrics/Metrics.java
Metrics.register
public <T> Gauge<T> register( final String component, final String methodName, final Gauge<T> gauge) { registry.register( MetricRegistry.name(component, methodName), new Gauge<T>() { @Override public T getValue() { return gauge.getValue(); } }); return gauge; }
java
public <T> Gauge<T> register( final String component, final String methodName, final Gauge<T> gauge) { registry.register( MetricRegistry.name(component, methodName), new Gauge<T>() { @Override public T getValue() { return gauge.getValue(); } }); return gauge; }
[ "public", "<", "T", ">", "Gauge", "<", "T", ">", "register", "(", "final", "String", "component", ",", "final", "String", "methodName", ",", "final", "Gauge", "<", "T", ">", "gauge", ")", "{", "registry", ".", "register", "(", "MetricRegistry", ".", "n...
Register a Gauge and service registry. @param component name for the requested timer. @param methodName for the requested timer. @param gauge instance. @return registered gauge in the service registry.
[ "Register", "a", "Gauge", "and", "service", "registry", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/metrics/Metrics.java#L49-L61
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/metrics/Metrics.java
Metrics.timer
public static Timer timer(Metrics metrics, String component, String methodName) { if (metrics != null) { return metrics.getTimer(component, methodName); } else { return null; } }
java
public static Timer timer(Metrics metrics, String component, String methodName) { if (metrics != null) { return metrics.getTimer(component, methodName); } else { return null; } }
[ "public", "static", "Timer", "timer", "(", "Metrics", "metrics", ",", "String", "component", ",", "String", "methodName", ")", "{", "if", "(", "metrics", "!=", "null", ")", "{", "return", "metrics", ".", "getTimer", "(", "component", ",", "methodName", ")"...
if metrics is not null returns a Timer instance for a given component and method name. @param metrics factory instance to get timer. @param component name for the requested timer. @param methodName for the requested timer. @return timer instance.
[ "if", "metrics", "is", "not", "null", "returns", "a", "Timer", "instance", "for", "a", "given", "component", "and", "method", "name", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/metrics/Metrics.java#L89-L95
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/metrics/Metrics.java
Metrics.counter
public static Counter counter(Metrics metrics, String component, String methodName) { if (metrics != null) { return metrics.getCounter(component, methodName); } else { return null; } }
java
public static Counter counter(Metrics metrics, String component, String methodName) { if (metrics != null) { return metrics.getCounter(component, methodName); } else { return null; } }
[ "public", "static", "Counter", "counter", "(", "Metrics", "metrics", ",", "String", "component", ",", "String", "methodName", ")", "{", "if", "(", "metrics", "!=", "null", ")", "{", "return", "metrics", ".", "getCounter", "(", "component", ",", "methodName",...
if metrics is not null returns a Counter instance for a given component and method name. @param metrics factory instance to get timer. @param component name for the requested timer. @param methodName for the requested timer. @return counter instance.
[ "if", "metrics", "is", "not", "null", "returns", "a", "Counter", "instance", "for", "a", "given", "component", "and", "method", "name", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/metrics/Metrics.java#L105-L111
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/engine/PriceLevel.java
PriceLevel.add
public Order add(long orderId, long size) { Order order = new Order(this, orderId, size); orders.add(order); return order; }
java
public Order add(long orderId, long size) { Order order = new Order(this, orderId, size); orders.add(order); return order; }
[ "public", "Order", "add", "(", "long", "orderId", ",", "long", "size", ")", "{", "Order", "order", "=", "new", "Order", "(", "this", ",", "orderId", ",", "size", ")", ";", "orders", ".", "add", "(", "order", ")", ";", "return", "order", ";", "}" ]
Add a new order. @param orderId the order id @param size the size @return the order added to this price level
[ "Add", "a", "new", "order", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/engine/PriceLevel.java#L48-L52
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/engine/PriceLevel.java
PriceLevel.match
public long match(long orderId, Side side, long size, EmitterProcessor<MatchOrder> matchEmmiter) { long quantity = size; while (quantity > 0 && !orders.isEmpty()) { Order order = orders.get(0); long orderQuantity = order.size(); if (orderQuantity > quantity) { order.reduce(quantity); matchEmmiter.onNext( new MatchOrder(order.id(), orderId, side, price, quantity, order.size())); quantity = 0; } else { orders.remove(0); matchEmmiter.onNext(new MatchOrder(order.id(), orderId, side, price, orderQuantity, 0)); quantity -= orderQuantity; } } return quantity; }
java
public long match(long orderId, Side side, long size, EmitterProcessor<MatchOrder> matchEmmiter) { long quantity = size; while (quantity > 0 && !orders.isEmpty()) { Order order = orders.get(0); long orderQuantity = order.size(); if (orderQuantity > quantity) { order.reduce(quantity); matchEmmiter.onNext( new MatchOrder(order.id(), orderId, side, price, quantity, order.size())); quantity = 0; } else { orders.remove(0); matchEmmiter.onNext(new MatchOrder(order.id(), orderId, side, price, orderQuantity, 0)); quantity -= orderQuantity; } } return quantity; }
[ "public", "long", "match", "(", "long", "orderId", ",", "Side", "side", ",", "long", "size", ",", "EmitterProcessor", "<", "MatchOrder", ">", "matchEmmiter", ")", "{", "long", "quantity", "=", "size", ";", "while", "(", "quantity", ">", "0", "&&", "!", ...
Match order if possible. @param orderId the incoming order id @param side the incoming order side @param size incoming order quantity @param matchEmmiter an emitter to be notified for matches {@link Processor#onNext(Object)} @return the remaining quantity of the incoming order
[ "Match", "order", "if", "possible", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/engine/PriceLevel.java#L63-L80
train
scalecube/scalecube-services
services-transport-rsocket/src/main/java/io/scalecube/services/transport/rsocket/DelegatedLoopResources.java
DelegatedLoopResources.newServerLoopResources
public static DelegatedLoopResources newServerLoopResources(EventLoopGroup workerGroup) { EventLoopGroup bossGroup = Epoll.isAvailable() ? new EpollEventLoopGroup(BOSS_THREADS_NUM, BOSS_THREAD_FACTORY) : new NioEventLoopGroup(BOSS_THREADS_NUM, BOSS_THREAD_FACTORY); return new DelegatedLoopResources(bossGroup, workerGroup); }
java
public static DelegatedLoopResources newServerLoopResources(EventLoopGroup workerGroup) { EventLoopGroup bossGroup = Epoll.isAvailable() ? new EpollEventLoopGroup(BOSS_THREADS_NUM, BOSS_THREAD_FACTORY) : new NioEventLoopGroup(BOSS_THREADS_NUM, BOSS_THREAD_FACTORY); return new DelegatedLoopResources(bossGroup, workerGroup); }
[ "public", "static", "DelegatedLoopResources", "newServerLoopResources", "(", "EventLoopGroup", "workerGroup", ")", "{", "EventLoopGroup", "bossGroup", "=", "Epoll", ".", "isAvailable", "(", ")", "?", "new", "EpollEventLoopGroup", "(", "BOSS_THREADS_NUM", ",", "BOSS_THRE...
Creates new loop resources for server side. @param workerGroup worker pool @return loop resources
[ "Creates", "new", "loop", "resources", "for", "server", "side", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-transport-rsocket/src/main/java/io/scalecube/services/transport/rsocket/DelegatedLoopResources.java#L57-L63
train
scalecube/scalecube-services
services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/ClientMessage.java
ClientMessage.hasData
public boolean hasData(Class<?> dataClass) { if (dataClass == null) { return false; } return dataClass.isPrimitive() ? hasData() : dataClass.isInstance(data); }
java
public boolean hasData(Class<?> dataClass) { if (dataClass == null) { return false; } return dataClass.isPrimitive() ? hasData() : dataClass.isInstance(data); }
[ "public", "boolean", "hasData", "(", "Class", "<", "?", ">", "dataClass", ")", "{", "if", "(", "dataClass", "==", "null", ")", "{", "return", "false", ";", "}", "return", "dataClass", ".", "isPrimitive", "(", ")", "?", "hasData", "(", ")", ":", "data...
Boolean method telling message contains data of given type or not. @param dataClass data class @return true if message has not null data of given type
[ "Boolean", "method", "telling", "message", "contains", "data", "of", "given", "type", "or", "not", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-gateway-clientsdk/src/main/java/io/scalecube/services/gateway/clientsdk/ClientMessage.java#L67-L73
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/ServiceEndpoint.java
ServiceEndpoint.serviceReferences
public Collection<ServiceReference> serviceReferences() { return serviceRegistrations.stream() .flatMap(sr -> sr.methods().stream().map(sm -> new ServiceReference(sm, sr, this))) .collect(Collectors.toList()); }
java
public Collection<ServiceReference> serviceReferences() { return serviceRegistrations.stream() .flatMap(sr -> sr.methods().stream().map(sm -> new ServiceReference(sm, sr, this))) .collect(Collectors.toList()); }
[ "public", "Collection", "<", "ServiceReference", ">", "serviceReferences", "(", ")", "{", "return", "serviceRegistrations", ".", "stream", "(", ")", ".", "flatMap", "(", "sr", "->", "sr", ".", "methods", "(", ")", ".", "stream", "(", ")", ".", "map", "("...
Creates collection of service references from this service endpoint. @return collection of {@link ServiceReference}
[ "Creates", "collection", "of", "service", "references", "from", "this", "service", "endpoint", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/ServiceEndpoint.java#L75-L79
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.oneWay
public Mono<Void> oneWay(ServiceMessage request) { return Mono.defer(() -> requestOne(request, Void.class).then()); }
java
public Mono<Void> oneWay(ServiceMessage request) { return Mono.defer(() -> requestOne(request, Void.class).then()); }
[ "public", "Mono", "<", "Void", ">", "oneWay", "(", "ServiceMessage", "request", ")", "{", "return", "Mono", ".", "defer", "(", "(", ")", "->", "requestOne", "(", "request", ",", "Void", ".", "class", ")", ".", "then", "(", ")", ")", ";", "}" ]
Issues fire-and-forget request. @param request request message to send. @return mono publisher completing normally or with error.
[ "Issues", "fire", "-", "and", "-", "forget", "request", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L121-L123
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.requestOne
public Mono<ServiceMessage> requestOne(ServiceMessage request, Class<?> responseType) { return Mono.defer( () -> { String qualifier = request.qualifier(); if (methodRegistry.containsInvoker(qualifier)) { // local service. return methodRegistry .getInvoker(request.qualifier()) .invokeOne(request, ServiceMessageCodec::decodeData) .map(this::throwIfError); } else { return addressLookup(request) .flatMap(address -> requestOne(request, responseType, address)); // remote service } }); }
java
public Mono<ServiceMessage> requestOne(ServiceMessage request, Class<?> responseType) { return Mono.defer( () -> { String qualifier = request.qualifier(); if (methodRegistry.containsInvoker(qualifier)) { // local service. return methodRegistry .getInvoker(request.qualifier()) .invokeOne(request, ServiceMessageCodec::decodeData) .map(this::throwIfError); } else { return addressLookup(request) .flatMap(address -> requestOne(request, responseType, address)); // remote service } }); }
[ "public", "Mono", "<", "ServiceMessage", ">", "requestOne", "(", "ServiceMessage", "request", ",", "Class", "<", "?", ">", "responseType", ")", "{", "return", "Mono", ".", "defer", "(", "(", ")", "->", "{", "String", "qualifier", "=", "request", ".", "qu...
Issues request-and-reply request. @param request request message to send. @param responseType type of response. @return mono publisher completing with single response message or with error.
[ "Issues", "request", "-", "and", "-", "reply", "request", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L153-L167
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.requestOne
public Mono<ServiceMessage> requestOne( ServiceMessage request, Class<?> responseType, Address address) { return Mono.defer( () -> { requireNonNull(address, "requestOne address parameter is required and must not be null"); requireNonNull(transport, "transport is required and must not be null"); return transport .create(address) .requestResponse(request) .map(message -> ServiceMessageCodec.decodeData(message, responseType)) .map(this::throwIfError); }); }
java
public Mono<ServiceMessage> requestOne( ServiceMessage request, Class<?> responseType, Address address) { return Mono.defer( () -> { requireNonNull(address, "requestOne address parameter is required and must not be null"); requireNonNull(transport, "transport is required and must not be null"); return transport .create(address) .requestResponse(request) .map(message -> ServiceMessageCodec.decodeData(message, responseType)) .map(this::throwIfError); }); }
[ "public", "Mono", "<", "ServiceMessage", ">", "requestOne", "(", "ServiceMessage", "request", ",", "Class", "<", "?", ">", "responseType", ",", "Address", "address", ")", "{", "return", "Mono", ".", "defer", "(", "(", ")", "->", "{", "requireNonNull", "(",...
Given an address issues request-and-reply request to a remote address. @param request request message to send. @param responseType type of response. @param address of remote target service to invoke. @return mono publisher completing with single response message or with error.
[ "Given", "an", "address", "issues", "request", "-", "and", "-", "reply", "request", "to", "a", "remote", "address", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L177-L189
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.requestMany
public Flux<ServiceMessage> requestMany(ServiceMessage request, Class<?> responseType) { return Flux.defer( () -> { String qualifier = request.qualifier(); if (methodRegistry.containsInvoker(qualifier)) { // local service. return methodRegistry .getInvoker(request.qualifier()) .invokeMany(request, ServiceMessageCodec::decodeData) .map(this::throwIfError); } else { return addressLookup(request) .flatMapMany( address -> requestMany(request, responseType, address)); // remote service } }); }
java
public Flux<ServiceMessage> requestMany(ServiceMessage request, Class<?> responseType) { return Flux.defer( () -> { String qualifier = request.qualifier(); if (methodRegistry.containsInvoker(qualifier)) { // local service. return methodRegistry .getInvoker(request.qualifier()) .invokeMany(request, ServiceMessageCodec::decodeData) .map(this::throwIfError); } else { return addressLookup(request) .flatMapMany( address -> requestMany(request, responseType, address)); // remote service } }); }
[ "public", "Flux", "<", "ServiceMessage", ">", "requestMany", "(", "ServiceMessage", "request", ",", "Class", "<", "?", ">", "responseType", ")", "{", "return", "Flux", ".", "defer", "(", "(", ")", "->", "{", "String", "qualifier", "=", "request", ".", "q...
Issues request to service which returns stream of service messages back. @param request request with given headers. @param responseType type of responses. @return flux publisher of service responses.
[ "Issues", "request", "to", "service", "which", "returns", "stream", "of", "service", "messages", "back", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L208-L223
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.requestMany
public Flux<ServiceMessage> requestMany( ServiceMessage request, Class<?> responseType, Address address) { return Flux.defer( () -> { requireNonNull(address, "requestMany address parameter is required and must not be null"); requireNonNull(transport, "transport is required and must not be null"); return transport .create(address) .requestStream(request) .map(message -> ServiceMessageCodec.decodeData(message, responseType)) .map(this::throwIfError); }); }
java
public Flux<ServiceMessage> requestMany( ServiceMessage request, Class<?> responseType, Address address) { return Flux.defer( () -> { requireNonNull(address, "requestMany address parameter is required and must not be null"); requireNonNull(transport, "transport is required and must not be null"); return transport .create(address) .requestStream(request) .map(message -> ServiceMessageCodec.decodeData(message, responseType)) .map(this::throwIfError); }); }
[ "public", "Flux", "<", "ServiceMessage", ">", "requestMany", "(", "ServiceMessage", "request", ",", "Class", "<", "?", ">", "responseType", ",", "Address", "address", ")", "{", "return", "Flux", ".", "defer", "(", "(", ")", "->", "{", "requireNonNull", "("...
Given an address issues request to remote service which returns stream of service messages back. @param request request with given headers. @param responseType type of responses. @param address of remote target service to invoke. @return flux publisher of service responses.
[ "Given", "an", "address", "issues", "request", "to", "remote", "service", "which", "returns", "stream", "of", "service", "messages", "back", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L234-L246
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.requestBidirectional
public Flux<ServiceMessage> requestBidirectional( Publisher<ServiceMessage> publisher, Class<?> responseType) { return Flux.from(publisher) .switchOnFirst( (first, messages) -> { if (first.hasValue()) { ServiceMessage request = first.get(); String qualifier = request.qualifier(); if (methodRegistry.containsInvoker(qualifier)) { // local service. return methodRegistry .getInvoker(qualifier) .invokeBidirectional(messages, ServiceMessageCodec::decodeData) .map(this::throwIfError); } else { // remote service return addressLookup(request) .flatMapMany( address -> requestBidirectional(messages, responseType, address)); } } return messages; }); }
java
public Flux<ServiceMessage> requestBidirectional( Publisher<ServiceMessage> publisher, Class<?> responseType) { return Flux.from(publisher) .switchOnFirst( (first, messages) -> { if (first.hasValue()) { ServiceMessage request = first.get(); String qualifier = request.qualifier(); if (methodRegistry.containsInvoker(qualifier)) { // local service. return methodRegistry .getInvoker(qualifier) .invokeBidirectional(messages, ServiceMessageCodec::decodeData) .map(this::throwIfError); } else { // remote service return addressLookup(request) .flatMapMany( address -> requestBidirectional(messages, responseType, address)); } } return messages; }); }
[ "public", "Flux", "<", "ServiceMessage", ">", "requestBidirectional", "(", "Publisher", "<", "ServiceMessage", ">", "publisher", ",", "Class", "<", "?", ">", "responseType", ")", "{", "return", "Flux", ".", "from", "(", "publisher", ")", ".", "switchOnFirst", ...
Issues stream of service requests to service which returns stream of service messages back. @param publisher of service requests. @param responseType type of responses. @return flux publisher of service responses.
[ "Issues", "stream", "of", "service", "requests", "to", "service", "which", "returns", "stream", "of", "service", "messages", "back", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L265-L289
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.requestBidirectional
public Flux<ServiceMessage> requestBidirectional( Publisher<ServiceMessage> publisher, Class<?> responseType, Address address) { return Flux.defer( () -> { requireNonNull( address, "requestBidirectional address parameter is required and must not be null"); requireNonNull(transport, "transport is required and must not be null"); return transport .create(address) .requestChannel(publisher) .map(message -> ServiceMessageCodec.decodeData(message, responseType)) .map(this::throwIfError); }); }
java
public Flux<ServiceMessage> requestBidirectional( Publisher<ServiceMessage> publisher, Class<?> responseType, Address address) { return Flux.defer( () -> { requireNonNull( address, "requestBidirectional address parameter is required and must not be null"); requireNonNull(transport, "transport is required and must not be null"); return transport .create(address) .requestChannel(publisher) .map(message -> ServiceMessageCodec.decodeData(message, responseType)) .map(this::throwIfError); }); }
[ "public", "Flux", "<", "ServiceMessage", ">", "requestBidirectional", "(", "Publisher", "<", "ServiceMessage", ">", "publisher", ",", "Class", "<", "?", ">", "responseType", ",", "Address", "address", ")", "{", "return", "Flux", ".", "defer", "(", "(", ")", ...
Given an address issues stream of service requests to service which returns stream of service messages back. @param publisher of service requests. @param responseType type of responses. @param address of remote target service to invoke. @return flux publisher of service responses.
[ "Given", "an", "address", "issues", "stream", "of", "service", "requests", "to", "service", "which", "returns", "stream", "of", "service", "messages", "back", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L300-L313
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.api
@SuppressWarnings("unchecked") public <T> T api(Class<T> serviceInterface) { final ServiceCall serviceCall = this; final Map<Method, MethodInfo> genericReturnTypes = Reflect.methodsInfo(serviceInterface); // noinspection unchecked return (T) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[] {serviceInterface}, (proxy, method, params) -> { final MethodInfo methodInfo = genericReturnTypes.get(method); final Class<?> returnType = methodInfo.parameterizedReturnType(); final boolean isServiceMessage = methodInfo.isRequestTypeServiceMessage(); Optional<Object> check = toStringOrEqualsOrHashCode(method.getName(), serviceInterface, params); if (check.isPresent()) { return check.get(); // toString, hashCode was invoked. } switch (methodInfo.communicationMode()) { case FIRE_AND_FORGET: return serviceCall.oneWay(toServiceMessage(methodInfo, params)); case REQUEST_RESPONSE: return serviceCall .requestOne(toServiceMessage(methodInfo, params), returnType) .transform(asMono(isServiceMessage)); case REQUEST_STREAM: return serviceCall .requestMany(toServiceMessage(methodInfo, params), returnType) .transform(asFlux(isServiceMessage)); case REQUEST_CHANNEL: // this is REQUEST_CHANNEL so it means params[0] must be a publisher - its safe to // cast. return serviceCall .requestBidirectional( Flux.from((Publisher) params[0]) .map(data -> toServiceMessage(methodInfo, data)), returnType) .transform(asFlux(isServiceMessage)); default: throw new IllegalArgumentException( "Communication mode is not supported: " + method); } }); }
java
@SuppressWarnings("unchecked") public <T> T api(Class<T> serviceInterface) { final ServiceCall serviceCall = this; final Map<Method, MethodInfo> genericReturnTypes = Reflect.methodsInfo(serviceInterface); // noinspection unchecked return (T) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[] {serviceInterface}, (proxy, method, params) -> { final MethodInfo methodInfo = genericReturnTypes.get(method); final Class<?> returnType = methodInfo.parameterizedReturnType(); final boolean isServiceMessage = methodInfo.isRequestTypeServiceMessage(); Optional<Object> check = toStringOrEqualsOrHashCode(method.getName(), serviceInterface, params); if (check.isPresent()) { return check.get(); // toString, hashCode was invoked. } switch (methodInfo.communicationMode()) { case FIRE_AND_FORGET: return serviceCall.oneWay(toServiceMessage(methodInfo, params)); case REQUEST_RESPONSE: return serviceCall .requestOne(toServiceMessage(methodInfo, params), returnType) .transform(asMono(isServiceMessage)); case REQUEST_STREAM: return serviceCall .requestMany(toServiceMessage(methodInfo, params), returnType) .transform(asFlux(isServiceMessage)); case REQUEST_CHANNEL: // this is REQUEST_CHANNEL so it means params[0] must be a publisher - its safe to // cast. return serviceCall .requestBidirectional( Flux.from((Publisher) params[0]) .map(data -> toServiceMessage(methodInfo, data)), returnType) .transform(asFlux(isServiceMessage)); default: throw new IllegalArgumentException( "Communication mode is not supported: " + method); } }); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "api", "(", "Class", "<", "T", ">", "serviceInterface", ")", "{", "final", "ServiceCall", "serviceCall", "=", "this", ";", "final", "Map", "<", "Method", ",", "MethodInfo", ...
Create proxy creates a java generic proxy instance by a given service interface. @param serviceInterface Service Interface type. @return newly created service proxy object.
[ "Create", "proxy", "creates", "a", "java", "generic", "proxy", "instance", "by", "a", "given", "service", "interface", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L321-L372
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/ServiceCall.java
ServiceCall.toStringOrEqualsOrHashCode
private Optional<Object> toStringOrEqualsOrHashCode( String method, Class<?> serviceInterface, Object... args) { switch (method) { case "toString": return Optional.of(serviceInterface.toString()); case "equals": return Optional.of(serviceInterface.equals(args[0])); case "hashCode": return Optional.of(serviceInterface.hashCode()); default: return Optional.empty(); } }
java
private Optional<Object> toStringOrEqualsOrHashCode( String method, Class<?> serviceInterface, Object... args) { switch (method) { case "toString": return Optional.of(serviceInterface.toString()); case "equals": return Optional.of(serviceInterface.equals(args[0])); case "hashCode": return Optional.of(serviceInterface.hashCode()); default: return Optional.empty(); } }
[ "private", "Optional", "<", "Object", ">", "toStringOrEqualsOrHashCode", "(", "String", "method", ",", "Class", "<", "?", ">", "serviceInterface", ",", "Object", "...", "args", ")", "{", "switch", "(", "method", ")", "{", "case", "\"toString\"", ":", "return...
check and handle toString or equals or hashcode method where invoked. @param method that was invoked. @param serviceInterface for a given service interface. @param args parameters that where invoked. @return Optional object as result of to string equals or hashCode result or absent if none of these where invoked.
[ "check", "and", "handle", "toString", "or", "equals", "or", "hashcode", "method", "where", "invoked", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/ServiceCall.java#L422-L436
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/Reflect.java
Reflect.inject
public static Microservices inject(Microservices microservices, Collection<Object> services) { services.forEach( service -> Arrays.stream(service.getClass().getDeclaredFields()) .forEach(field -> injectField(microservices, field, service))); services.forEach(service -> processAfterConstruct(microservices, service)); return microservices; }
java
public static Microservices inject(Microservices microservices, Collection<Object> services) { services.forEach( service -> Arrays.stream(service.getClass().getDeclaredFields()) .forEach(field -> injectField(microservices, field, service))); services.forEach(service -> processAfterConstruct(microservices, service)); return microservices; }
[ "public", "static", "Microservices", "inject", "(", "Microservices", "microservices", ",", "Collection", "<", "Object", ">", "services", ")", "{", "services", ".", "forEach", "(", "service", "->", "Arrays", ".", "stream", "(", "service", ".", "getClass", "(", ...
Inject instances to the microservices instance. either Microservices or ServiceProxy. Scan all local service instances and inject a service proxy. @param microservices microservices instance @param services services set @return microservices instance
[ "Inject", "instances", "to", "the", "microservices", "instance", ".", "either", "Microservices", "or", "ServiceProxy", ".", "Scan", "all", "local", "service", "instances", "and", "inject", "a", "service", "proxy", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/Reflect.java#L50-L57
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/Reflect.java
Reflect.parameterizedType
public static Type parameterizedType(Object object) { if (object != null) { Type type = object.getClass().getGenericSuperclass(); if (type instanceof ParameterizedType) { return ((ParameterizedType) type).getActualTypeArguments()[0]; } } return Object.class; }
java
public static Type parameterizedType(Object object) { if (object != null) { Type type = object.getClass().getGenericSuperclass(); if (type instanceof ParameterizedType) { return ((ParameterizedType) type).getActualTypeArguments()[0]; } } return Object.class; }
[ "public", "static", "Type", "parameterizedType", "(", "Object", "object", ")", "{", "if", "(", "object", "!=", "null", ")", "{", "Type", "type", "=", "object", ".", "getClass", "(", ")", ".", "getGenericSuperclass", "(", ")", ";", "if", "(", "type", "i...
Util function that returns the parameterizedType of a given object. @param object to inspect @return the parameterized Type of a given object or Object class if unknown.
[ "Util", "function", "that", "returns", "the", "parameterizedType", "of", "a", "given", "object", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/Reflect.java#L117-L125
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/Reflect.java
Reflect.parameterizedRequestType
public static Type parameterizedRequestType(Method method) { if (method != null && method.getGenericParameterTypes().length > 0) { Type type = method.getGenericParameterTypes()[0]; if (type instanceof ParameterizedType) { return ((ParameterizedType) type).getActualTypeArguments()[0]; } } return Object.class; }
java
public static Type parameterizedRequestType(Method method) { if (method != null && method.getGenericParameterTypes().length > 0) { Type type = method.getGenericParameterTypes()[0]; if (type instanceof ParameterizedType) { return ((ParameterizedType) type).getActualTypeArguments()[0]; } } return Object.class; }
[ "public", "static", "Type", "parameterizedRequestType", "(", "Method", "method", ")", "{", "if", "(", "method", "!=", "null", "&&", "method", ".", "getGenericParameterTypes", "(", ")", ".", "length", ">", "0", ")", "{", "Type", "type", "=", "method", ".", ...
Util function that returns the parameterized of the request Type of a given object. @return the parameterized Type of a given object or Object class if unknown.
[ "Util", "function", "that", "returns", "the", "parameterized", "of", "the", "request", "Type", "of", "a", "given", "object", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/Reflect.java#L156-L165
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/Reflect.java
Reflect.serviceInterfaces
public static Collection<Class<?>> serviceInterfaces(Object serviceObject) { Class<?>[] interfaces = serviceObject.getClass().getInterfaces(); return Arrays.stream(interfaces) .filter(interfaceClass -> interfaceClass.isAnnotationPresent(Service.class)) .collect(Collectors.toList()); }
java
public static Collection<Class<?>> serviceInterfaces(Object serviceObject) { Class<?>[] interfaces = serviceObject.getClass().getInterfaces(); return Arrays.stream(interfaces) .filter(interfaceClass -> interfaceClass.isAnnotationPresent(Service.class)) .collect(Collectors.toList()); }
[ "public", "static", "Collection", "<", "Class", "<", "?", ">", ">", "serviceInterfaces", "(", "Object", "serviceObject", ")", "{", "Class", "<", "?", ">", "[", "]", "interfaces", "=", "serviceObject", ".", "getClass", "(", ")", ".", "getInterfaces", "(", ...
Util function to get service interfaces collections from service instance. @param serviceObject with extends service interface with @Service annotation. @return service interface class.
[ "Util", "function", "to", "get", "service", "interfaces", "collections", "from", "service", "instance", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/Reflect.java#L206-L211
train
scalecube/scalecube-services
services/src/main/java/io/scalecube/services/Reflect.java
Reflect.validateMethodOrThrow
public static void validateMethodOrThrow(Method method) { Class<?> returnType = method.getReturnType(); if (returnType.equals(Void.TYPE)) { return; } else if (!Publisher.class.isAssignableFrom(returnType)) { throw new UnsupportedOperationException("Service method return type can be Publisher only"); } if (method.getParameterCount() > 1) { throw new UnsupportedOperationException("Service method can accept 0 or 1 parameters only"); } }
java
public static void validateMethodOrThrow(Method method) { Class<?> returnType = method.getReturnType(); if (returnType.equals(Void.TYPE)) { return; } else if (!Publisher.class.isAssignableFrom(returnType)) { throw new UnsupportedOperationException("Service method return type can be Publisher only"); } if (method.getParameterCount() > 1) { throw new UnsupportedOperationException("Service method can accept 0 or 1 parameters only"); } }
[ "public", "static", "void", "validateMethodOrThrow", "(", "Method", "method", ")", "{", "Class", "<", "?", ">", "returnType", "=", "method", ".", "getReturnType", "(", ")", ";", "if", "(", "returnType", ".", "equals", "(", "Void", ".", "TYPE", ")", ")", ...
Util function to perform basic validation of service message request. @param method service method.
[ "Util", "function", "to", "perform", "basic", "validation", "of", "service", "message", "request", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services/src/main/java/io/scalecube/services/Reflect.java#L227-L237
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/exceptions/ExceptionMapperExample.java
ExceptionMapperExample.main
public static void main(String[] args) throws InterruptedException { Microservices ms1 = Microservices.builder() .discovery(ScalecubeServiceDiscovery::new) .transport(ServiceTransports::rsocketServiceTransport) .defaultErrorMapper(new ServiceAProviderErrorMapper()) // default mapper for whole node .services( ServiceInfo.fromServiceInstance(new ServiceAImpl()) .errorMapper(new ServiceAProviderErrorMapper()) // mapper per service instance .build()) .startAwait(); System.err.println("ms1 started: " + ms1.serviceAddress()); Microservices ms2 = Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, ms1)) .transport(ServiceTransports::rsocketServiceTransport) .services( call -> { ServiceA serviceA = call.errorMapper( new ServiceAClientErrorMapper()) // service client error mapper .api(ServiceA.class); ServiceB serviceB = new ServiceBImpl(serviceA); return Collections.singleton(ServiceInfo.fromServiceInstance(serviceB).build()); }) .startAwait(); System.err.println("ms2 started: " + ms2.serviceAddress()); ms2.call() .api(ServiceB.class) .doAnotherStuff(0) .subscribe( System.out::println, th -> System.err.println( "No service client mapper is defined for ServiceB, " + "so default scalecube mapper is used! -> " + th), () -> System.out.println("Completed!")); Thread.currentThread().join(); }
java
public static void main(String[] args) throws InterruptedException { Microservices ms1 = Microservices.builder() .discovery(ScalecubeServiceDiscovery::new) .transport(ServiceTransports::rsocketServiceTransport) .defaultErrorMapper(new ServiceAProviderErrorMapper()) // default mapper for whole node .services( ServiceInfo.fromServiceInstance(new ServiceAImpl()) .errorMapper(new ServiceAProviderErrorMapper()) // mapper per service instance .build()) .startAwait(); System.err.println("ms1 started: " + ms1.serviceAddress()); Microservices ms2 = Microservices.builder() .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, ms1)) .transport(ServiceTransports::rsocketServiceTransport) .services( call -> { ServiceA serviceA = call.errorMapper( new ServiceAClientErrorMapper()) // service client error mapper .api(ServiceA.class); ServiceB serviceB = new ServiceBImpl(serviceA); return Collections.singleton(ServiceInfo.fromServiceInstance(serviceB).build()); }) .startAwait(); System.err.println("ms2 started: " + ms2.serviceAddress()); ms2.call() .api(ServiceB.class) .doAnotherStuff(0) .subscribe( System.out::println, th -> System.err.println( "No service client mapper is defined for ServiceB, " + "so default scalecube mapper is used! -> " + th), () -> System.out.println("Completed!")); Thread.currentThread().join(); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "InterruptedException", "{", "Microservices", "ms1", "=", "Microservices", ".", "builder", "(", ")", ".", "discovery", "(", "ScalecubeServiceDiscovery", "::", "new", ")", ".", ...
Example runner. @param args program arguments. @throws InterruptedException exception.
[ "Example", "runner", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/exceptions/ExceptionMapperExample.java#L20-L66
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/methods/ServiceMethodInvoker.java
ServiceMethodInvoker.invokeOne
public Mono<ServiceMessage> invokeOne( ServiceMessage message, BiFunction<ServiceMessage, Class<?>, ServiceMessage> dataDecoder) { return Mono.defer(() -> Mono.from(invoke(toRequest(message, dataDecoder)))) .map(this::toResponse) .onErrorResume(throwable -> Mono.just(errorMapper.toMessage(throwable))); }
java
public Mono<ServiceMessage> invokeOne( ServiceMessage message, BiFunction<ServiceMessage, Class<?>, ServiceMessage> dataDecoder) { return Mono.defer(() -> Mono.from(invoke(toRequest(message, dataDecoder)))) .map(this::toResponse) .onErrorResume(throwable -> Mono.just(errorMapper.toMessage(throwable))); }
[ "public", "Mono", "<", "ServiceMessage", ">", "invokeOne", "(", "ServiceMessage", "message", ",", "BiFunction", "<", "ServiceMessage", ",", "Class", "<", "?", ">", ",", "ServiceMessage", ">", "dataDecoder", ")", "{", "return", "Mono", ".", "defer", "(", "(",...
Invokes service method with single response. @param message request service message @param dataDecoder function to create new service message with decoded data @return mono of service message
[ "Invokes", "service", "method", "with", "single", "response", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/methods/ServiceMethodInvoker.java#L51-L56
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/methods/ServiceMethodInvoker.java
ServiceMethodInvoker.invokeMany
public Flux<ServiceMessage> invokeMany( ServiceMessage message, BiFunction<ServiceMessage, Class<?>, ServiceMessage> dataDecoder) { return Flux.defer(() -> Flux.from(invoke(toRequest(message, dataDecoder)))) .map(this::toResponse) .onErrorResume(throwable -> Flux.just(errorMapper.toMessage(throwable))); }
java
public Flux<ServiceMessage> invokeMany( ServiceMessage message, BiFunction<ServiceMessage, Class<?>, ServiceMessage> dataDecoder) { return Flux.defer(() -> Flux.from(invoke(toRequest(message, dataDecoder)))) .map(this::toResponse) .onErrorResume(throwable -> Flux.just(errorMapper.toMessage(throwable))); }
[ "public", "Flux", "<", "ServiceMessage", ">", "invokeMany", "(", "ServiceMessage", "message", ",", "BiFunction", "<", "ServiceMessage", ",", "Class", "<", "?", ">", ",", "ServiceMessage", ">", "dataDecoder", ")", "{", "return", "Flux", ".", "defer", "(", "("...
Invokes service method with message stream response. @param message request service message @param dataDecoder function to create new service message with decoded data @return flux of service messages
[ "Invokes", "service", "method", "with", "message", "stream", "response", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/methods/ServiceMethodInvoker.java#L65-L70
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/methods/ServiceMethodInvoker.java
ServiceMethodInvoker.invokeBidirectional
public Flux<ServiceMessage> invokeBidirectional( Publisher<ServiceMessage> publisher, BiFunction<ServiceMessage, Class<?>, ServiceMessage> dataDecoder) { return Flux.from(publisher) .map(message -> toRequest(message, dataDecoder)) .transform(this::invoke) .map(this::toResponse) .onErrorResume(throwable -> Flux.just(errorMapper.toMessage(throwable))); }
java
public Flux<ServiceMessage> invokeBidirectional( Publisher<ServiceMessage> publisher, BiFunction<ServiceMessage, Class<?>, ServiceMessage> dataDecoder) { return Flux.from(publisher) .map(message -> toRequest(message, dataDecoder)) .transform(this::invoke) .map(this::toResponse) .onErrorResume(throwable -> Flux.just(errorMapper.toMessage(throwable))); }
[ "public", "Flux", "<", "ServiceMessage", ">", "invokeBidirectional", "(", "Publisher", "<", "ServiceMessage", ">", "publisher", ",", "BiFunction", "<", "ServiceMessage", ",", "Class", "<", "?", ">", ",", "ServiceMessage", ">", "dataDecoder", ")", "{", "return", ...
Invokes service method with bidirectional communication. @param publisher request service message @param dataDecoder function to create new service message with decoded data @return flux of service messages
[ "Invokes", "service", "method", "with", "bidirectional", "communication", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/methods/ServiceMethodInvoker.java#L79-L87
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/transport/api/ServiceMessageCodec.java
ServiceMessageCodec.decode
public ServiceMessage decode(ByteBuf dataBuffer, ByteBuf headersBuffer) throws MessageCodecException { ServiceMessage.Builder builder = ServiceMessage.builder(); if (dataBuffer.isReadable()) { builder.data(dataBuffer); } if (headersBuffer.isReadable()) { try (ByteBufInputStream stream = new ByteBufInputStream(headersBuffer, true)) { builder.headers(headersCodec.decode(stream)); } catch (Throwable ex) { ReferenceCountUtil.safestRelease(dataBuffer); // release data buf as well throw new MessageCodecException("Failed to decode message headers", ex); } } return builder.build(); }
java
public ServiceMessage decode(ByteBuf dataBuffer, ByteBuf headersBuffer) throws MessageCodecException { ServiceMessage.Builder builder = ServiceMessage.builder(); if (dataBuffer.isReadable()) { builder.data(dataBuffer); } if (headersBuffer.isReadable()) { try (ByteBufInputStream stream = new ByteBufInputStream(headersBuffer, true)) { builder.headers(headersCodec.decode(stream)); } catch (Throwable ex) { ReferenceCountUtil.safestRelease(dataBuffer); // release data buf as well throw new MessageCodecException("Failed to decode message headers", ex); } } return builder.build(); }
[ "public", "ServiceMessage", "decode", "(", "ByteBuf", "dataBuffer", ",", "ByteBuf", "headersBuffer", ")", "throws", "MessageCodecException", "{", "ServiceMessage", ".", "Builder", "builder", "=", "ServiceMessage", ".", "builder", "(", ")", ";", "if", "(", "dataBuf...
Decode buffers. @param dataBuffer the buffer of the data (payload) @param headersBuffer the buffer of the headers @return a new Service message with {@link ByteBuf} data and with parsed headers. @throws MessageCodecException when decode fails
[ "Decode", "buffers", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/transport/api/ServiceMessageCodec.java#L79-L96
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/transport/api/ServiceMessageCodec.java
ServiceMessageCodec.decodeData
public static ServiceMessage decodeData(ServiceMessage message, Class<?> dataType) throws MessageCodecException { if (dataType == null || !message.hasData(ByteBuf.class) || ((ByteBuf) message.data()).readableBytes() == 0) { return message; } Object data; Class<?> targetType = message.isError() ? ErrorData.class : dataType; ByteBuf dataBuffer = message.data(); try (ByteBufInputStream inputStream = new ByteBufInputStream(dataBuffer, true)) { DataCodec dataCodec = DataCodec.getInstance(message.dataFormatOrDefault()); data = dataCodec.decode(inputStream, targetType); } catch (Throwable ex) { throw new MessageCodecException( "Failed to decode data on message q=" + message.qualifier(), ex); } return ServiceMessage.from(message).data(data).build(); }
java
public static ServiceMessage decodeData(ServiceMessage message, Class<?> dataType) throws MessageCodecException { if (dataType == null || !message.hasData(ByteBuf.class) || ((ByteBuf) message.data()).readableBytes() == 0) { return message; } Object data; Class<?> targetType = message.isError() ? ErrorData.class : dataType; ByteBuf dataBuffer = message.data(); try (ByteBufInputStream inputStream = new ByteBufInputStream(dataBuffer, true)) { DataCodec dataCodec = DataCodec.getInstance(message.dataFormatOrDefault()); data = dataCodec.decode(inputStream, targetType); } catch (Throwable ex) { throw new MessageCodecException( "Failed to decode data on message q=" + message.qualifier(), ex); } return ServiceMessage.from(message).data(data).build(); }
[ "public", "static", "ServiceMessage", "decodeData", "(", "ServiceMessage", "message", ",", "Class", "<", "?", ">", "dataType", ")", "throws", "MessageCodecException", "{", "if", "(", "dataType", "==", "null", "||", "!", "message", ".", "hasData", "(", "ByteBuf...
Decode message. @param message the original message (with {@link ByteBuf} data) @param dataType the type of the data. @return a new Service message that upon {@link ServiceMessage#data()} returns the actual data (of type data type) @throws MessageCodecException when decode fails
[ "Decode", "message", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/transport/api/ServiceMessageCodec.java#L107-L128
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/engine/OrderBook.java
OrderBook.enter
public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) { return; } if (side == Side.BUY) { buy(orderId, price, size); } else { sell(orderId, price, size); } }
java
public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) { return; } if (side == Side.BUY) { buy(orderId, price, size); } else { sell(orderId, price, size); } }
[ "public", "void", "enter", "(", "long", "orderId", ",", "Side", "side", ",", "long", "price", ",", "long", "size", ")", "{", "if", "(", "orders", ".", "containsKey", "(", "orderId", ")", ")", "{", "return", ";", "}", "if", "(", "side", "==", "Side"...
Enter an order to this order book. <p>The incoming order is first matched against resting orders in this order book. This operation results in zero or more Match events. <p>If the remaining quantity is not zero after the matching operation, the remaining quantity is added to this order book and an Add event is triggered. <p>If the order identifier is known, do nothing. @param orderId an order identifier @param side the side @param price the limit price @param size the size
[ "Enter", "an", "order", "to", "this", "order", "book", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/engine/OrderBook.java#L51-L61
train
scalecube/scalecube-services
services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/engine/OrderBook.java
OrderBook.cancel
public void cancel(long orderId, long size) { Order order = orders.get(orderId); if (order == null) { return; } long remainingQuantity = order.size(); if (size >= remainingQuantity) { return; } if (size > 0) { order.resize(size); } else { delete(order); orders.remove(orderId); } cancelListener.onNext(new CancelOrder(orderId, remainingQuantity - size, size)); }
java
public void cancel(long orderId, long size) { Order order = orders.get(orderId); if (order == null) { return; } long remainingQuantity = order.size(); if (size >= remainingQuantity) { return; } if (size > 0) { order.resize(size); } else { delete(order); orders.remove(orderId); } cancelListener.onNext(new CancelOrder(orderId, remainingQuantity - size, size)); }
[ "public", "void", "cancel", "(", "long", "orderId", ",", "long", "size", ")", "{", "Order", "order", "=", "orders", ".", "get", "(", "orderId", ")", ";", "if", "(", "order", "==", "null", ")", "{", "return", ";", "}", "long", "remainingQuantity", "="...
Cancel a quantity of an order in this order book. The size refers to the new order size. If the new order size is set to zero, the order is deleted from this order book. <p>A Cancel event is triggered. <p>If the order identifier is unknown, do nothing. @param orderId the order identifier @param size the new size
[ "Cancel", "a", "quantity", "of", "an", "order", "in", "this", "order", "book", ".", "The", "size", "refers", "to", "the", "new", "order", "size", ".", "If", "the", "new", "order", "size", "is", "set", "to", "zero", "the", "order", "is", "deleted", "f...
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-examples/src/main/java/io/scalecube/services/examples/orderbook/service/engine/OrderBook.java#L112-L132
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/ServiceLoaderUtil.java
ServiceLoaderUtil.findFirst
public static <T> Optional<T> findFirst(Class<T> clazz) { ServiceLoader<T> load = ServiceLoader.load(clazz); return StreamSupport.stream(load.spliterator(), false).findFirst(); }
java
public static <T> Optional<T> findFirst(Class<T> clazz) { ServiceLoader<T> load = ServiceLoader.load(clazz); return StreamSupport.stream(load.spliterator(), false).findFirst(); }
[ "public", "static", "<", "T", ">", "Optional", "<", "T", ">", "findFirst", "(", "Class", "<", "T", ">", "clazz", ")", "{", "ServiceLoader", "<", "T", ">", "load", "=", "ServiceLoader", ".", "load", "(", "clazz", ")", ";", "return", "StreamSupport", "...
Finds the first implementation of the given service type and creates its instance. @param clazz service type @return the first implementation of the given service type
[ "Finds", "the", "first", "implementation", "of", "the", "given", "service", "type", "and", "creates", "its", "instance", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/ServiceLoaderUtil.java#L21-L24
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/ServiceLoaderUtil.java
ServiceLoaderUtil.findFirst
public static <T> Optional<T> findFirst(Class<T> clazz, Predicate<? super T> predicate) { ServiceLoader<T> load = ServiceLoader.load(clazz); Stream<T> stream = StreamSupport.stream(load.spliterator(), false); return stream.filter(predicate).findFirst(); }
java
public static <T> Optional<T> findFirst(Class<T> clazz, Predicate<? super T> predicate) { ServiceLoader<T> load = ServiceLoader.load(clazz); Stream<T> stream = StreamSupport.stream(load.spliterator(), false); return stream.filter(predicate).findFirst(); }
[ "public", "static", "<", "T", ">", "Optional", "<", "T", ">", "findFirst", "(", "Class", "<", "T", ">", "clazz", ",", "Predicate", "<", "?", "super", "T", ">", "predicate", ")", "{", "ServiceLoader", "<", "T", ">", "load", "=", "ServiceLoader", ".", ...
Finds the first implementation of the given service type using the given predicate to filter out found service types and creates its instance. @param clazz service type @param predicate service type predicate @return the first implementation of the given service type
[ "Finds", "the", "first", "implementation", "of", "the", "given", "service", "type", "using", "the", "given", "predicate", "to", "filter", "out", "found", "service", "types", "and", "creates", "its", "instance", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/ServiceLoaderUtil.java#L34-L38
train
scalecube/scalecube-services
services-api/src/main/java/io/scalecube/services/ServiceLoaderUtil.java
ServiceLoaderUtil.findAll
public static <T> Stream<T> findAll(Class<T> clazz) { ServiceLoader<T> load = ServiceLoader.load(clazz); return StreamSupport.stream(load.spliterator(), false); }
java
public static <T> Stream<T> findAll(Class<T> clazz) { ServiceLoader<T> load = ServiceLoader.load(clazz); return StreamSupport.stream(load.spliterator(), false); }
[ "public", "static", "<", "T", ">", "Stream", "<", "T", ">", "findAll", "(", "Class", "<", "T", ">", "clazz", ")", "{", "ServiceLoader", "<", "T", ">", "load", "=", "ServiceLoader", ".", "load", "(", "clazz", ")", ";", "return", "StreamSupport", ".", ...
Finds all implementations of the given service type and creates their instances. @param clazz service type @return implementations' stream of the given service type
[ "Finds", "all", "implementations", "of", "the", "given", "service", "type", "and", "creates", "their", "instances", "." ]
76c8de6019e5480a1436d12b37acf163f70eea47
https://github.com/scalecube/scalecube-services/blob/76c8de6019e5480a1436d12b37acf163f70eea47/services-api/src/main/java/io/scalecube/services/ServiceLoaderUtil.java#L46-L49
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/LocalDocumentStore.java
LocalDocumentStore.put
@RequiresTransaction public void put( String key, Document document ) { database.put(key, document); }
java
@RequiresTransaction public void put( String key, Document document ) { database.put(key, document); }
[ "@", "RequiresTransaction", "public", "void", "put", "(", "String", "key", ",", "Document", "document", ")", "{", "database", ".", "put", "(", "key", ",", "document", ")", ";", "}" ]
Store the supplied document and metadata at the given key. @param key the key or identifier for the document @param document the document that is to be stored @see SchematicDb#put(String, Document)
[ "Store", "the", "supplied", "document", "and", "metadata", "at", "the", "given", "key", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/LocalDocumentStore.java#L119-L123
train
ModeShape/modeshape
modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/LocalDocumentStore.java
LocalDocumentStore.runInTransaction
public <V> V runInTransaction( Callable<V> operation, int retryCountOnLockTimeout, String... keysToLock ) { // Start a transaction ... Transactions txns = repoEnv.getTransactions(); int retryCount = retryCountOnLockTimeout; try { Transactions.Transaction txn = txns.begin(); if (keysToLock.length > 0) { List<String> keysList = Arrays.asList(keysToLock); boolean locksAcquired = false; while (!locksAcquired && retryCountOnLockTimeout-- >= 0) { locksAcquired = lockDocuments(keysList); } if (!locksAcquired) { txn.rollback(); throw new org.modeshape.jcr.TimeoutException( "Cannot acquire locks on: " + Arrays.toString(keysToLock) + " after " + retryCount + " attempts"); } } try { V result = operation.call(); txn.commit(); return result; } catch (Exception e) { // always rollback txn.rollback(); // throw as is (see below) throw e; } } catch (IllegalStateException | SystemException | NotSupportedException err) { throw new SystemFailureException(err); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } }
java
public <V> V runInTransaction( Callable<V> operation, int retryCountOnLockTimeout, String... keysToLock ) { // Start a transaction ... Transactions txns = repoEnv.getTransactions(); int retryCount = retryCountOnLockTimeout; try { Transactions.Transaction txn = txns.begin(); if (keysToLock.length > 0) { List<String> keysList = Arrays.asList(keysToLock); boolean locksAcquired = false; while (!locksAcquired && retryCountOnLockTimeout-- >= 0) { locksAcquired = lockDocuments(keysList); } if (!locksAcquired) { txn.rollback(); throw new org.modeshape.jcr.TimeoutException( "Cannot acquire locks on: " + Arrays.toString(keysToLock) + " after " + retryCount + " attempts"); } } try { V result = operation.call(); txn.commit(); return result; } catch (Exception e) { // always rollback txn.rollback(); // throw as is (see below) throw e; } } catch (IllegalStateException | SystemException | NotSupportedException err) { throw new SystemFailureException(err); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "<", "V", ">", "V", "runInTransaction", "(", "Callable", "<", "V", ">", "operation", ",", "int", "retryCountOnLockTimeout", ",", "String", "...", "keysToLock", ")", "{", "// Start a transaction ...", "Transactions", "txns", "=", "repoEnv", ".", "getTra...
Runs the given operation within a transaction, after optionally locking some keys. @param operation a {@link Callable} instance; may not be null @param retryCountOnLockTimeout the number of times the operation should be retried if a timeout occurs while trying to obtain the locks @param keysToLock an optional {@link String[]} representing the keys to lock before performing the operation @param <V> the return type of the operation @return the result of operation
[ "Runs", "the", "given", "operation", "within", "a", "transaction", "after", "optionally", "locking", "some", "keys", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/cache/document/LocalDocumentStore.java#L281-L316
train
ModeShape/modeshape
modeshape-common/src/main/java/org/modeshape/common/statistic/Histogram.java
Histogram.setStrategy
public void setStrategy( double median, double standardDeviation, int sigma ) { this.bucketingStrategy = new StandardDeviationBucketingStrategy(median, standardDeviation, sigma); this.bucketWidth = null; }
java
public void setStrategy( double median, double standardDeviation, int sigma ) { this.bucketingStrategy = new StandardDeviationBucketingStrategy(median, standardDeviation, sigma); this.bucketWidth = null; }
[ "public", "void", "setStrategy", "(", "double", "median", ",", "double", "standardDeviation", ",", "int", "sigma", ")", "{", "this", ".", "bucketingStrategy", "=", "new", "StandardDeviationBucketingStrategy", "(", "median", ",", "standardDeviation", ",", "sigma", ...
Set the histogram to use the standard deviation to determine the bucket sizes. @param median @param standardDeviation @param sigma
[ "Set", "the", "histogram", "to", "use", "the", "standard", "deviation", "to", "determine", "the", "bucket", "sizes", "." ]
794cfdabb67a90f24629c4fff0424a6125f8f95b
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/statistic/Histogram.java#L81-L86
train