idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
139,600 | @ Override public int read ( byte [ ] buffer , int offset , int length ) throws IOException { try { if ( _length < length ) length = ( int ) _length ; if ( length <= 0 ) return - 1 ; int len = _next . read ( buffer , offset , length ) ; if ( len > 0 ) { _length -= len ; } else { _length = - 1 ; } return len ; } catch ( SocketTimeoutException e ) { throw new ClientDisconnectException ( e ) ; } } | Reads from the buffer limiting to the content length . | 110 | 11 |
139,601 | @ Override public String format ( LogRecord log ) { StringBuilder sb = new StringBuilder ( ) ; int mark = 0 ; for ( FormatItem item : _formatList ) { item . format ( sb , log , mark ) ; if ( item instanceof PrettyPrintMarkItem ) { mark = sb . length ( ) ; } } return sb . toString ( ) ; } | Formats the record | 83 | 4 |
139,602 | @ Override public StreamBuilderImpl < T , U > reduce ( T init , BinaryOperatorSync < T > op ) { return new ReduceOpInitSync <> ( this , init , op ) ; } | Reduce with a binary function | 44 | 6 |
139,603 | @ Override public < R > StreamBuilderImpl < R , U > reduce ( R identity , BiFunctionSync < R , ? super T , R > accumulator , BinaryOperatorSync < R > combiner ) { return new ReduceAccumSync <> ( this , identity , accumulator , combiner ) ; } | Reduce with an accumulator and combiner | 67 | 9 |
139,604 | public void setModified ( boolean isModified ) { _isModified = isModified ; if ( _isModified ) _checkExpiresTime = Long . MAX_VALUE / 2 ; else _checkExpiresTime = CurrentTime . currentTime ( ) + _checkInterval ; if ( ! isModified ) _isModifiedLog = false ; } | Sets the modified . | 78 | 5 |
139,605 | private static ServiceWeb buildWebService ( WebBuilder builder , Function < RequestWeb , Object > beanFactory , Method method ) { Parameter [ ] params = method . getParameters ( ) ; WebParam [ ] webParam = new WebParam [ params . length ] ; for ( int i = 0 ; i < params . length ; i ++ ) { webParam [ i ] = buildParam ( builder , params [ i ] ) ; } return new WebServiceMethod ( beanFactory , method , webParam ) ; } | Builds a HTTP service from a method . | 106 | 9 |
139,606 | public String getAttribute ( String key ) { List < String > values = _headers . get ( key . toLowerCase ( Locale . ENGLISH ) ) ; if ( values != null && values . size ( ) > 0 ) return values . get ( 0 ) ; return null ; } | Returns a read attribute from the multipart mime . | 61 | 11 |
139,607 | public int getAvailable ( ) throws IOException { if ( _isPartDone ) return 0 ; else if ( _peekOffset < _peekLength ) return _peekLength - _peekOffset ; else { int ch = read ( ) ; if ( ch < 0 ) return 0 ; _peekOffset = 0 ; _peekLength = 1 ; _peek [ 0 ] = ( byte ) ch ; return 1 ; } } | Returns the number of available bytes . | 93 | 7 |
139,608 | @ Override public int read ( byte [ ] buffer , int offset , int length ) throws IOException { int b = - 1 ; if ( _isPartDone ) return - 1 ; int i = 0 ; // Need the last peek or would miss the initial '\n' while ( _peekOffset + 1 < _peekLength && length > 0 ) { buffer [ offset + i ++ ] = _peek [ _peekOffset ++ ] ; length -- ; } while ( i < length && ( b = read ( ) ) >= 0 ) { boolean hasCr = false ; if ( b == ' ' ) { hasCr = true ; b = read ( ) ; // XXX: Macintosh? if ( b != ' ' ) { buffer [ offset + i ++ ] = ( byte ) ' ' ; _peek [ 0 ] = ( byte ) b ; _peekOffset = 0 ; _peekLength = 1 ; continue ; } } else if ( b != ' ' ) { buffer [ offset + i ++ ] = ( byte ) b ; continue ; } int j ; for ( j = 0 ; j < _boundaryLength && ( b = read ( ) ) >= 0 && _boundaryBuffer [ j ] == b ; j ++ ) { } if ( j == _boundaryLength ) { _isPartDone = true ; if ( ( b = read ( ) ) == ' ' ) { if ( ( b = read ( ) ) == ' ' ) { _isDone = true ; _isComplete = true ; } } for ( ; b > 0 && b != ' ' && b != ' ' ; b = read ( ) ) { } if ( b == ' ' && ( b = read ( ) ) != ' ' ) { _peek [ 0 ] = ( byte ) b ; _peekOffset = 0 ; _peekLength = 1 ; } return i > 0 ? i : - 1 ; } _peekLength = 0 ; if ( hasCr && i + 1 < length ) { buffer [ offset + i ++ ] = ( byte ) ' ' ; buffer [ offset + i ++ ] = ( byte ) ' ' ; } else if ( hasCr ) { buffer [ offset + i ++ ] = ( byte ) ' ' ; _peek [ _peekLength ++ ] = ( byte ) ' ' ; } else { buffer [ offset + i ++ ] = ( byte ) ' ' ; } int k = 0 ; while ( k < j && i + 1 < length ) buffer [ offset + i ++ ] = _boundaryBuffer [ k ++ ] ; while ( k < j ) _peek [ _peekLength ++ ] = _boundaryBuffer [ k ++ ] ; _peek [ _peekLength ++ ] = ( byte ) b ; _peekOffset = 0 ; } if ( i <= 0 ) { _isPartDone = true ; if ( b < 0 ) _isDone = true ; return - 1 ; } else { return i ; } } | Reads from the multipart mime buffer . | 632 | 10 |
139,609 | @ Override public ServiceRefAmp ref ( ) { if ( _isForeign ) { return null ; } if ( workers ( ) > 1 ) { return buildWorkers ( ) ; } if ( _worker != null ) { return buildWorker ( ) ; } else { //throw new IllegalStateException(L.l("build() requires a worker or resource.")); return buildService ( ) ; } } | Build the service and return the service ref . | 86 | 9 |
139,610 | private ServiceRefAmp service ( StubFactoryAmp stubFactory ) { validateOpen ( ) ; Thread thread = Thread . currentThread ( ) ; ClassLoader oldLoader = thread . getContextClassLoader ( ) ; OutboxAmp outbox = OutboxAmp . current ( ) ; Object oldContext = null ; try { thread . setContextClassLoader ( _services . classLoader ( ) ) ; if ( outbox != null ) { oldContext = outbox . getAndSetContext ( _services . inboxSystem ( ) ) ; } //return serviceImpl(beanFactory, address, config); ServiceRefAmp serviceRef = serviceImpl ( stubFactory ) ; String address = stubFactory . address ( ) ; if ( address != null ) { _services . bind ( serviceRef , address ) ; } if ( serviceRef . stub ( ) . isAutoStart ( ) || stubFactory . config ( ) . isAutoStart ( ) ) { _services . addAutoStart ( serviceRef ) ; } return serviceRef ; } finally { thread . setContextClassLoader ( oldLoader ) ; if ( outbox != null ) { outbox . getAndSetContext ( oldContext ) ; } } } | Main service builder . Called from ServiceBuilder and ServiceRefBean . | 250 | 14 |
139,611 | ServiceRefAmp service ( QueueServiceFactoryInbox serviceFactory , ServiceConfig config ) { QueueDeliverBuilderImpl < MessageAmp > queueBuilder = new QueueDeliverBuilderImpl <> ( ) ; //queueBuilder.setOutboxFactory(OutboxAmpFactory.newFactory()); queueBuilder . setClassLoader ( _services . classLoader ( ) ) ; queueBuilder . sizeMax ( config . queueSizeMax ( ) ) ; queueBuilder . size ( config . queueSize ( ) ) ; InboxAmp inbox = new InboxQueue ( _services , queueBuilder , serviceFactory , config ) ; return inbox . serviceRef ( ) ; } | Used by journal builder . | 140 | 5 |
139,612 | public QueryBuilderKraken parse ( ) { Token token = scanToken ( ) ; switch ( token ) { case CREATE : return parseCreate ( ) ; case EXPLAIN : return parseExplain ( ) ; case INSERT : return parseInsert ( ) ; case REPLACE : return parseReplace ( ) ; case SELECT : return parseSelect ( ) ; case SELECT_LOCAL : return parseSelectLocal ( ) ; case MAP : return parseMap ( ) ; case SHOW : return parseShow ( ) ; case UPDATE : return parseUpdate ( ) ; case DELETE : return parseDelete ( ) ; case WATCH : return parseWatch ( ) ; /* case NOTIFY: return parseNotify(); */ /* case VALIDATE: return parseValidate(); case DROP: return parseDrop(); */ case IDENTIFIER : if ( _lexeme . equalsIgnoreCase ( "checkpoint" ) ) { return parseCheckpoint ( ) ; } default : throw error ( "unknown query at {0}" , token ) ; } } | Parses the query . | 217 | 6 |
139,613 | private ExprKraken parseSelectExpr ( ) { Token token = scanToken ( ) ; if ( token == Token . STAR ) { // return new UnboundStarExpr(); throw new UnsupportedOperationException ( getClass ( ) . getName ( ) ) ; } else { _token = token ; return parseExpr ( ) ; } } | Parses a select expression . | 74 | 7 |
139,614 | private QueryBuilderKraken parseCreate ( ) { Token token ; // TableBuilderKraken factory = null;// = _database.createTableFactory(); if ( ( token = scanToken ( ) ) != Token . TABLE ) throw error ( "expected TABLE at '{0}'" , token ) ; if ( ( token = scanToken ( ) ) != Token . IDENTIFIER ) throw error ( "expected identifier at '{0}'" , token ) ; String name = _lexeme ; String pod = null ; while ( peekToken ( ) == Token . DOT ) { scanToken ( ) ; if ( ( token = scanToken ( ) ) != Token . IDENTIFIER ) { throw error ( "expected identifier at '{0}'" , token ) ; } if ( pod == null ) { pod = name ; } else { pod = pod + ' ' + name ; } name = _lexeme ; } if ( pod == null ) { pod = getPodName ( ) ; } TableBuilderKraken factory = new TableBuilderKraken ( pod , name , _sql ) ; // factory.startTable(_lexeme); if ( ( token = scanToken ( ) ) != Token . LPAREN ) { throw error ( "expected '(' at '{0}'" , token ) ; } do { token = scanToken ( ) ; switch ( token ) { case IDENTIFIER : parseCreateColumn ( factory , _lexeme ) ; break ; /* case UNIQUE: token = scanToken(); if (token != KEY) { _token = token; } factory.addUnique(parseColumnNames()); break; */ case PRIMARY : token = scanToken ( ) ; if ( token != Token . KEY ) throw error ( "expected 'key' at {0}" , token ) ; factory . addPrimaryKey ( parseColumnNames ( ) ) ; break ; case KEY : //String key = parseIdentifier(); factory . addPrimaryKey ( parseColumnNames ( ) ) ; // factory.addPrimaryKey(parseColumnNames()); break ; /* case CHECK: if ((token = scanToken()) != '(') throw error(L.l("Expected '(' at '{0}'", tokenName(token))); parseExpr(); if ((token = scanToken()) != ')') throw error(L.l("Expected ')' at '{0}'", tokenName(token))); break; */ default : throw error ( "unexpected token '{0}'" , token ) ; } token = scanToken ( ) ; } while ( token == Token . COMMA ) ; if ( token != Token . RPAREN ) { throw error ( "expected ')' at '{0}'" , token ) ; } token = scanToken ( ) ; HashMap < String , String > propMap = new HashMap <> ( ) ; if ( token == Token . WITH ) { do { String key = parseIdentifier ( ) ; ExprKraken expr = parseExpr ( ) ; if ( ! ( expr instanceof LiteralExpr ) ) { throw error ( "WITH expression must be a literal at '{0}'" , expr ) ; } String value = expr . evalString ( null ) ; propMap . put ( key , value ) ; } while ( ( token = scanToken ( ) ) == Token . COMMA ) ; } if ( token != Token . EOF ) { throw error ( "Expected end of file at '{0}'" , token ) ; } return new CreateQueryBuilder ( _tableManager , factory , _sql , propMap ) ; } | Parses the create . | 766 | 6 |
139,615 | public void parseReferences ( ArrayList < String > name ) { String foreignTable = parseIdentifier ( ) ; Token token = scanToken ( ) ; ArrayList < String > foreignColumns = new ArrayList < String > ( ) ; if ( token == Token . LPAREN ) { _token = token ; foreignColumns = parseColumnNames ( ) ; } else { _token = token ; } } | Parses the references clause . | 85 | 7 |
139,616 | public ArrayList < String > parseColumnNames ( ) { ArrayList < String > columns = new ArrayList < String > ( ) ; Token token = scanToken ( ) ; if ( token == Token . LPAREN ) { do { columns . add ( parseIdentifier ( ) ) ; token = scanToken ( ) ; } while ( token == Token . COMMA ) ; if ( token != Token . RPAREN ) { throw error ( "expected ')' at '{0}'" , token ) ; } } else if ( token == Token . IDENTIFIER ) { columns . add ( _lexeme ) ; _token = token ; } else { throw error ( "expected '(' at '{0}'" , token ) ; } return columns ; } | Parses a list of column names | 160 | 8 |
139,617 | private QueryBuilderKraken parseInsert ( ) { Token token ; if ( ( token = scanToken ( ) ) != Token . INTO ) { throw error ( "expected INTO at '{0}'" , token ) ; } TableKraken table = parseTable ( ) ; Objects . requireNonNull ( table ) ; TableKelp tableKelp = table . getTableKelp ( ) ; ArrayList < Column > columns = new ArrayList <> ( ) ; boolean isKeyHash = false ; if ( ( token = scanToken ( ) ) == Token . LPAREN ) { do { String columnName = parseIdentifier ( ) ; Column column = tableKelp . getColumn ( columnName ) ; if ( column == null ) { throw error ( "'{0}' is not a valid column in {1}" , columnName , table . getName ( ) ) ; } columns . add ( column ) ; } while ( ( token = scanToken ( ) ) == Token . COMMA ) ; if ( token != Token . RPAREN ) { throw error ( "expected ')' at '{0}'" , token ) ; } token = scanToken ( ) ; } else { for ( Column column : tableKelp . getColumns ( ) ) { if ( column . name ( ) . startsWith ( ":" ) ) { continue ; } columns . add ( column ) ; } } if ( token != Token . VALUES ) throw error ( "expected VALUES at '{0}'" , token ) ; if ( ( token = scanToken ( ) ) != Token . LPAREN ) { throw error ( "expected '(' at '{0}'" , token ) ; } ArrayList < ExprKraken > values = new ArrayList <> ( ) ; InsertQueryBuilder query ; query = new InsertQueryBuilder ( this , _sql , table , columns ) ; _query = query ; do { ExprKraken expr = parseExpr ( ) ; //expr = expr.bind(new TempQueryBuilder(table)); values . add ( expr ) ; } while ( ( token = scanToken ( ) ) == Token . COMMA ) ; if ( token != Token . RPAREN ) { throw error ( "expected ')' at '{0}'" , token ) ; } if ( columns . size ( ) != values . size ( ) ) { throw error ( "number of columns does not match number of values" ) ; } ParamExpr [ ] params = _params . toArray ( new ParamExpr [ _params . size ( ) ] ) ; query . setParams ( params ) ; query . setValues ( values ) ; // query.init(); return query ; } | Parses the insert . | 575 | 6 |
139,618 | private QueryBuilderKraken parseUpdate ( ) { Token token ; UpdateQueryBuilder query = new UpdateQueryBuilder ( _tableManager , _sql ) ; String tableName = parseTableName ( ) ; query . setTableName ( tableName ) ; _query = query ; if ( ( token = scanToken ( ) ) != Token . SET ) { throw error ( L . l ( "expected SET at {0}" , token ) ) ; } do { parseSetItem ( query ) ; } while ( ( token = scanToken ( ) ) == Token . COMMA ) ; _token = token ; //query.setUpdateBuilder(new SetUpdateBuilder(setItems)); ExprKraken whereExpr = null ; token = scanToken ( ) ; if ( token == Token . WHERE ) { whereExpr = parseExpr ( ) ; } else if ( token != null && token != Token . EOF ) { throw error ( "expected WHERE at '{0}'" , token ) ; } ParamExpr [ ] params = _params . toArray ( new ParamExpr [ _params . size ( ) ] ) ; query . setParams ( params ) ; query . setWhereExpr ( whereExpr ) ; return query ; } | Parses the update . | 262 | 6 |
139,619 | private void parseSetItem ( UpdateQueryBuilder query ) { Token token ; if ( ( token = scanToken ( ) ) != Token . IDENTIFIER ) { throw error ( L . l ( "expected identifier at '{0}'" , token ) ) ; } String columnName = _lexeme ; if ( ( token = scanToken ( ) ) != Token . EQ ) { throw error ( "expected '=' at {0}" , token ) ; } ExprKraken expr = parseExpr ( ) ; query . addItem ( columnName , expr ) ; } | Parses a set item . | 121 | 7 |
139,620 | private ExprKraken parseAndExpr ( ) { // AndExpr oldAndExpr = _andExpr; AndExpr andExpr = new AndExpr ( ) ; // _andExpr = andExpr; andExpr . add ( parseNotExpr ( ) ) ; while ( true ) { Token token = scanToken ( ) ; switch ( token ) { case AND : andExpr . add ( parseNotExpr ( ) ) ; break ; default : _token = token ; // _andExpr = oldAndExpr; return andExpr . getSingleExpr ( ) ; } } } | Parses an AND expression . | 135 | 7 |
139,621 | private ExprKraken parseCmpExpr ( ) { // Expr left = parseConcatExpr(); ExprKraken left = parseAddExpr ( ) ; Token token = scanToken ( ) ; boolean isNot = false ; /* if (token == NOT) { isNot = true; token = scanToken(); if (token != BETWEEN && token != LIKE && token != IN) { _token = token; return left; } } */ switch ( token ) { case EQ : return new BinaryExpr ( BinaryOp . EQ , left , parseAddExpr ( ) ) ; case NE : return new BinaryExpr ( BinaryOp . NE , left , parseAddExpr ( ) ) ; case LT : return new BinaryExpr ( BinaryOp . LT , left , parseAddExpr ( ) ) ; case LE : return new BinaryExpr ( BinaryOp . LE , left , parseAddExpr ( ) ) ; case GT : return new BinaryExpr ( BinaryOp . GT , left , parseAddExpr ( ) ) ; case GE : return new BinaryExpr ( BinaryOp . GE , left , parseAddExpr ( ) ) ; case BETWEEN : { ExprKraken min = parseAddExpr ( ) ; token = scanToken ( ) ; if ( token != Token . AND ) throw error ( L . l ( "expected AND at '{0}'" , token ) ) ; ExprKraken max = parseAddExpr ( ) ; return new BetweenExpr ( left , min , max , isNot ) ; } /* case LT: case LE: case GT: case GE: case NE: return new CmpExpr(left, parseConcatExpr(), token); case BETWEEN: { Expr min = parseConcatExpr(); token = scanToken(); if (token != AND) throw error(L.l("expected AND at '{0}'", tokenName(token))); Expr max = parseConcatExpr(); return new BetweenExpr(left, min, max, isNot); } case IS: { token = scanToken(); isNot = false; if (token == NOT) { token = scanToken(); isNot = true; } if (token == NULL) return new IsNullExpr(left, isNot); else throw error(L.l("expected NULL at '{0}'", tokenName(token))); } case LIKE: { token = scanToken(); if (token == STRING) return new LikeExpr(left, _lexeme, isNot); else throw error(L.l("expected string at '{0}'", tokenName(token))); } case IN: { HashSet<String> values = parseInValues(); return new InExpr(left, values, isNot); } */ default : _token = token ; return left ; } } | Parses a CMP expression . | 614 | 8 |
139,622 | private ExprKraken parseSimpleTerm ( ) { Token token = scanToken ( ) ; switch ( token ) { case MINUS : return new UnaryExpr ( UnaryOp . MINUS , parseSimpleTerm ( ) ) ; case LPAREN : { ExprKraken expr = parseExpr ( ) ; if ( ( token = scanToken ( ) ) != Token . RPAREN ) { throw error ( "Expected ')' at '{0}'" , token ) ; } return expr ; } case IDENTIFIER : { String name = _lexeme ; if ( ( token = peekToken ( ) ) == Token . DOT ) { return parsePath ( name ) ; } else if ( token == Token . LPAREN ) { FunExpr fun = null ; /* if (name.equalsIgnoreCase("max")) fun = new MaxExpr(); else if (name.equalsIgnoreCase("min")) fun = new MinExpr(); else if (name.equalsIgnoreCase("sum")) fun = new SumExpr(); else if (name.equalsIgnoreCase("avg")) fun = new AvgExpr(); else if (name.equalsIgnoreCase("count")) { fun = new CountExpr(); token = scanToken(); if (token == '*') { fun.addArg(new UnboundStarExpr()); } else _token = token; } else */ { String funName = ( Character . toUpperCase ( name . charAt ( 0 ) ) + name . substring ( 1 ) . toLowerCase ( Locale . ENGLISH ) ) ; funName = "com.caucho.v5.kraken.fun." + funName + "Expr" ; try { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; Class < ? > cl = Class . forName ( funName , false , loader ) ; fun = ( FunExpr ) cl . newInstance ( ) ; } catch ( ClassNotFoundException e ) { log . finer ( e . toString ( ) ) ; } catch ( Exception e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; throw error ( e . toString ( ) ) ; } if ( fun == null ) { throw error ( L . l ( "'{0}' is an unknown function." , name ) ) ; } } scanToken ( ) ; token = peekToken ( ) ; while ( token != null && token != Token . RPAREN ) { ExprKraken arg = parseExpr ( ) ; fun . addArg ( arg ) ; token = peekToken ( ) ; if ( token == Token . COMMA ) { scanToken ( ) ; token = peekToken ( ) ; } } scanToken ( ) ; return fun ; } else { return new IdExprBuilder ( name ) ; } } case STRING : return new LiteralExpr ( _lexeme ) ; case DOUBLE : return new LiteralExpr ( Double . parseDouble ( _lexeme ) ) ; case INTEGER : return new LiteralExpr ( Long . parseLong ( _lexeme ) ) ; case LONG : return new LiteralExpr ( Long . parseLong ( _lexeme ) ) ; case NULL : return new NullExpr ( ) ; case TRUE : return new LiteralExpr ( true ) ; case FALSE : return new LiteralExpr ( false ) ; case QUESTION_MARK : ParamExpr param = new ParamExpr ( _params . size ( ) ) ; _params . add ( param ) ; return param ; default : throw error ( "unexpected term {0}" , token ) ; } } | Parses a simple term . | 795 | 7 |
139,623 | private String parseIdentifier ( ) { Token token = scanToken ( ) ; if ( token != Token . IDENTIFIER ) { throw error ( "expected identifier at {0}" , token ) ; } return _lexeme ; } | Parses an identifier . | 49 | 6 |
139,624 | @ Override public I get ( ) { I instance = _instance ; if ( instance == null || instance . isModified ( ) ) { _instance = instance = service ( ) . get ( ) ; } return instance ; } | Returns the current instance . | 48 | 5 |
139,625 | public V put ( K key , V value ) { Entry < V > oldValue = _cache . put ( key , new Entry < V > ( _expireInterval , value ) ) ; if ( oldValue != null ) return oldValue . getValue ( ) ; else return null ; } | Put a new item in the cache . | 62 | 8 |
139,626 | public V get ( K key ) { Entry < V > entry = _cache . get ( key ) ; if ( entry == null ) return null ; if ( entry . isValid ( ) ) return entry . getValue ( ) ; else { _cache . remove ( key ) ; return null ; } } | Gets an item from the cache returning null if expired . | 63 | 12 |
139,627 | private int parseUtf8 ( InputStream is , int length ) throws IOException { if ( length <= 0 ) return 0 ; if ( length > 256 ) { is . skip ( length ) ; return 0 ; } int offset = _charBufferOffset ; if ( _charBuffer . length <= offset + length ) { char [ ] buffer = new char [ 2 * _charBuffer . length ] ; System . arraycopy ( _charBuffer , 0 , buffer , 0 , _charBuffer . length ) ; _charBuffer = buffer ; } char [ ] buffer = _charBuffer ; boolean [ ] isJavaIdentifier = IS_JAVA_IDENTIFIER ; boolean isIdentifier = true ; while ( length > 0 ) { int d1 = is . read ( ) ; char ch ; if ( d1 == ' ' ) { ch = ' ' ; length -- ; } else if ( d1 < 0x80 ) { ch = ( char ) d1 ; length -- ; } else if ( d1 < 0xe0 ) { int d2 = is . read ( ) & 0x3f ; ch = ( char ) ( ( ( d1 & 0x1f ) << 6 ) + ( d2 ) ) ; length -= 2 ; } else if ( d1 < 0xf0 ) { int d2 = is . read ( ) & 0x3f ; int d3 = is . read ( ) & 0x3f ; ch = ( char ) ( ( ( d1 & 0xf ) << 12 ) + ( d2 << 6 ) + d3 ) ; length -= 3 ; } else throw new IllegalStateException ( ) ; if ( isIdentifier && isJavaIdentifier [ ch ] ) { buffer [ offset ++ ] = ch ; } else { isIdentifier = false ; } } if ( ! isIdentifier ) return 0 ; int charLength = offset - _charBufferOffset ; _charBufferOffset = offset ; return charLength ; } | Parses the UTF . | 415 | 6 |
139,628 | private void scanAttributeForAnnotation ( InputStream is ) throws IOException { int nameIndex = readShort ( is ) ; // String name = _cp.getUtf8(nameIndex).getValue(); int length = readInt ( is ) ; if ( ! isNameAnnotation ( nameIndex ) ) { is . skip ( length ) ; return ; } int count = readShort ( is ) ; for ( int i = 0 ; i < count ; i ++ ) { int annTypeIndex = scanAnnotation ( is ) ; if ( annTypeIndex > 0 && _cpLengths [ annTypeIndex ] > 2 ) { _matcher . addClassAnnotation ( _charBuffer , _cpData [ annTypeIndex ] + 1 , _cpLengths [ annTypeIndex ] - 2 ) ; } } } | Parses an attribute for an annotation . | 173 | 9 |
139,629 | public static long toPeriod ( String value , long defaultUnits ) throws ConfigException { if ( value == null ) return 0 ; long sign = 1 ; long period = 0 ; int i = 0 ; int length = value . length ( ) ; if ( length > 0 && value . charAt ( i ) == ' ' ) { sign = - 1 ; i ++ ; } while ( i < length ) { long delta = 0 ; char ch ; for ( ; i < length && ( ch = value . charAt ( i ) ) >= ' ' && ch <= ' ' ; i ++ ) delta = 10 * delta + ch - ' ' ; if ( length <= i ) period += defaultUnits * delta ; else { ch = value . charAt ( i ++ ) ; switch ( ch ) { case ' ' : period += 1000 * delta ; break ; case ' ' : if ( i < value . length ( ) && value . charAt ( i ) == ' ' ) { i ++ ; period += delta ; } else period += 60 * 1000 * delta ; break ; case ' ' : period += 60L * 60 * 1000 * delta ; break ; case ' ' : period += DAY * delta ; break ; case ' ' : period += 7L * DAY * delta ; break ; case ' ' : period += 30L * DAY * delta ; break ; case ' ' : period += 365L * DAY * delta ; break ; default : throw new ConfigException ( L . l ( "Unknown unit `{0}' in period `{1}'. Valid units are:\n '10ms' milliseconds\n '10s' seconds\n '10m' minutes\n '10h' hours\n '10D' days\n '10W' weeks\n '10M' months\n '10Y' years" , String . valueOf ( ch ) , value ) ) ; } } } period = sign * period ; // server/137w /* if (period < 0) return INFINITE; else return period; */ return period ; } | Converts a period string to a time . | 432 | 9 |
139,630 | static HttpStreamWrapper openRead ( HttpPath path ) throws IOException { HttpStream stream = createStream ( path ) ; stream . _isPost = false ; HttpStreamWrapper wrapper = new HttpStreamWrapper ( stream ) ; String status = ( String ) wrapper . getAttribute ( "status" ) ; // ioc/23p0 if ( "404" . equals ( status ) ) { throw new FileNotFoundException ( L . l ( "'{0}' returns a HTTP 404." , path . getURL ( ) ) ) ; } return wrapper ; } | Opens a new HTTP stream for reading i . e . a GET request . | 125 | 16 |
139,631 | static HttpStreamWrapper openReadWrite ( HttpPath path ) throws IOException { HttpStream stream = createStream ( path ) ; stream . _isPost = true ; return new HttpStreamWrapper ( stream ) ; } | Opens a new HTTP stream for reading and writing i . e . a POST request . | 50 | 18 |
139,632 | static private HttpStream createStream ( HttpPath path ) throws IOException { String host = path . getHost ( ) ; int port = path . getPort ( ) ; HttpStream stream = null ; long streamTime = 0 ; synchronized ( LOCK ) { if ( _savedStream != null && host . equals ( _savedStream . getHost ( ) ) && port == _savedStream . getPort ( ) ) { stream = _savedStream ; streamTime = _saveTime ; _savedStream = null ; } } if ( stream != null ) { long now ; now = CurrentTime . currentTime ( ) ; if ( now < streamTime + 5000 ) { // if the stream is still valid, use it stream . init ( path ) ; return stream ; } else { // if the stream has timed out, close it try { stream . _isKeepalive = false ; stream . close ( ) ; } catch ( IOException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; } } } Socket s ; try { s = new Socket ( host , port ) ; if ( path instanceof HttpsPath ) { SSLContext context = SSLContext . getInstance ( "TLS" ) ; javax . net . ssl . TrustManager tm = new javax . net . ssl . X509TrustManager ( ) { public java . security . cert . X509Certificate [ ] getAcceptedIssuers ( ) { return null ; } public void checkClientTrusted ( java . security . cert . X509Certificate [ ] cert , String foo ) { } public void checkServerTrusted ( java . security . cert . X509Certificate [ ] cert , String foo ) { } } ; context . init ( null , new javax . net . ssl . TrustManager [ ] { tm } , null ) ; SSLSocketFactory factory = context . getSocketFactory ( ) ; s = factory . createSocket ( s , host , port , true ) ; } } catch ( ConnectException e ) { throw new ConnectException ( path . getURL ( ) + ": " + e . getMessage ( ) ) ; } catch ( Exception e ) { throw new ConnectException ( path . getURL ( ) + ": " + e . toString ( ) ) ; } int socketTimeout = 300 * 1000 ; try { s . setSoTimeout ( socketTimeout ) ; } catch ( Exception e ) { } return new HttpStream ( path , host , port , s ) ; } | Creates a new HTTP stream . If there is a saved connection to the same host use it . | 546 | 20 |
139,633 | private void init ( PathImpl path ) { _contentLength = - 1 ; _isChunked = false ; _isRequestDone = false ; _didGet = false ; _isPost = false ; _isHead = false ; _method = null ; _attributes . clear ( ) ; //setPath(path); if ( path instanceof HttpPath ) _virtualHost = ( ( HttpPath ) path ) . getVirtualHost ( ) ; } | Initializes the stream for the next request . | 97 | 9 |
139,634 | private void getConnInput ( ) throws IOException { if ( _didGet ) return ; try { getConnInputImpl ( ) ; } catch ( IOException e ) { _isKeepalive = false ; throw e ; } catch ( RuntimeException e ) { _isKeepalive = false ; throw e ; } } | Sends the request and initializes the response . | 68 | 10 |
139,635 | public void setPathFormat ( String pathFormat ) throws ConfigException { _pathFormat = pathFormat ; if ( pathFormat . endsWith ( ".zip" ) ) { throw new ConfigException ( L . l ( ".zip extension to path-format is not supported." ) ) ; } } | Sets the formatted path . | 60 | 6 |
139,636 | public void setArchiveFormat ( String format ) { if ( format . endsWith ( ".gz" ) ) { _archiveFormat = format . substring ( 0 , format . length ( ) - ".gz" . length ( ) ) ; _archiveSuffix = ".gz" ; } else if ( format . endsWith ( ".zip" ) ) { _archiveFormat = format . substring ( 0 , format . length ( ) - ".zip" . length ( ) ) ; _archiveSuffix = ".zip" ; } else { _archiveFormat = format ; _archiveSuffix = "" ; } } | Sets the archive name format | 130 | 6 |
139,637 | public void setRolloverPeriod ( Duration period ) { _rolloverPeriod = period . toMillis ( ) ; if ( _rolloverPeriod > 0 ) { _rolloverPeriod += 3600000L - 1 ; _rolloverPeriod -= _rolloverPeriod % 3600000L ; } else _rolloverPeriod = Integer . MAX_VALUE ; // Period.INFINITE; } | Sets the log rollover period rounded up to the nearest hour . | 87 | 14 |
139,638 | public void setRolloverCheckPeriod ( long period ) { if ( period > 1000 ) _rolloverCheckPeriod = period ; else if ( period > 0 ) _rolloverCheckPeriod = 1000 ; if ( DAY < _rolloverCheckPeriod ) { log . info ( this + " rollover-check-period " + _rolloverCheckPeriod + "ms is longer than 24h" ) ; _rolloverCheckPeriod = DAY ; } } | Sets how often the log rollover will be checked . | 99 | 12 |
139,639 | @ Override public void write ( byte [ ] buffer , int offset , int length ) throws IOException { synchronized ( _logLock ) { if ( _isRollingOver && getTempStreamMax ( ) < _tempStreamSize ) { try { _logLock . wait ( ) ; } catch ( Exception e ) { } } if ( ! _isRollingOver ) { if ( _os == null ) openLog ( ) ; if ( _os != null ) _os . write ( buffer , offset , length ) ; } else { // XXX: throw new UnsupportedOperationException ( getClass ( ) . getName ( ) ) ; /* if (_tempStream == null) { _tempStream = createTempStream(); _tempStreamSize = 0; } _tempStreamSize += length; _tempStream.write(buffer, offset, length); */ } } } | Writes to the underlying log . | 182 | 7 |
139,640 | private void rolloverLogTask ( ) { try { if ( _isInit ) { flush ( ) ; } } catch ( Exception e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } _isRollingOver = true ; try { if ( ! _isInit ) return ; Path savedPath = null ; long now = CurrentTime . currentTime ( ) ; long lastPeriodEnd = _nextPeriodEnd ; _nextPeriodEnd = nextRolloverTime ( now ) ; Path path = getPath ( ) ; synchronized ( _logLock ) { flushTempStream ( ) ; long length = Files . size ( path ) ; if ( lastPeriodEnd <= now && lastPeriodEnd > 0 ) { closeLogStream ( ) ; savedPath = getSavedPath ( lastPeriodEnd - 1 ) ; } else if ( path != null && getRolloverSize ( ) <= length ) { closeLogStream ( ) ; savedPath = getSavedPath ( now ) ; } } // archiving of path is outside of the synchronized block to // avoid freezing during archive if ( savedPath != null ) { movePathToArchive ( savedPath ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { synchronized ( _logLock ) { _isRollingOver = false ; flushTempStream ( ) ; } _rolloverListener . requeue ( _rolloverAlarm ) ; } } | Called from rollover worker | 314 | 6 |
139,641 | private void openLog ( ) { closeLogStream ( ) ; WriteStream os = _os ; _os = null ; IoUtil . close ( os ) ; Path path = getPath ( ) ; if ( path == null ) { path = getPath ( CurrentTime . currentTime ( ) ) ; } Path parent = path . getParent ( ) ; try { if ( ! Files . isDirectory ( parent ) ) { Files . createDirectory ( parent ) ; } } catch ( Exception e ) { logWarning ( L . l ( "Can't create log directory {0}.\n Exception={1}" , parent , e ) , e ) ; } Exception exn = null ; for ( int i = 0 ; i < 3 && _os == null ; i ++ ) { try { OutputStream out = Files . newOutputStream ( path , StandardOpenOption . APPEND ) ; _os = new WriteStream ( out ) ; } catch ( IOException e ) { exn = e ; } } String pathName = path . toString ( ) ; try { if ( pathName . endsWith ( ".gz" ) ) { _zipOut = _os ; _os = new WriteStream ( new GZIPOutputStream ( _zipOut ) ) ; } else if ( pathName . endsWith ( ".zip" ) ) { throw new ConfigException ( "Can't support .zip in path-format" ) ; } } catch ( Exception e ) { if ( exn == null ) exn = e ; } if ( exn != null ) logWarning ( L . l ( "Can't create log for {0}.\n User={1} Exception={2}" , path , System . getProperty ( "user.name" ) , exn ) , exn ) ; } | Tries to open the log . Called from inside _logLock | 375 | 13 |
139,642 | private void removeOldLogs ( ) { try { Path path = getPath ( ) ; Path parent = path . getParent ( ) ; ArrayList < String > matchList = new ArrayList < String > ( ) ; Pattern archiveRegexp = getArchiveRegexp ( ) ; Files . list ( parent ) . forEach ( child -> { String subPath = child . getFileName ( ) . toString ( ) ; Matcher matcher = archiveRegexp . matcher ( subPath ) ; if ( matcher . matches ( ) ) matchList . add ( subPath ) ; } ) ; Collections . sort ( matchList ) ; if ( _rolloverCount <= 0 || matchList . size ( ) < _rolloverCount ) return ; for ( int i = 0 ; i + _rolloverCount < matchList . size ( ) ; i ++ ) { try { Files . delete ( parent . resolve ( matchList . get ( i ) ) ) ; } catch ( Throwable e ) { } } } catch ( Throwable e ) { } } | Removes logs passing the rollover count . | 225 | 9 |
139,643 | protected Path getPath ( long time ) { String formatString = getPathFormat ( ) ; if ( formatString == null ) throw new IllegalStateException ( L . l ( "getPath requires a format path" ) ) ; String pathString = getFormatName ( formatString , time ) ; return getPwd ( ) . resolve ( pathString ) ; } | Returns the path of the format file | 75 | 7 |
139,644 | public void close ( ) throws IOException { _isClosed = true ; _rolloverWorker . wake ( ) ; _rolloverWorker . close ( ) ; synchronized ( _logLock ) { closeLogStream ( ) ; } Alarm alarm = _rolloverAlarm ; _rolloverAlarm = null ; if ( alarm != null ) alarm . dequeue ( ) ; } | Closes the log flushing the results . | 82 | 9 |
139,645 | private void closeLogStream ( ) { try { WriteStream os = _os ; _os = null ; if ( os != null ) os . close ( ) ; } catch ( Throwable e ) { // can't log in log routines } try { WriteStream zipOut = _zipOut ; _zipOut = null ; if ( zipOut != null ) zipOut . close ( ) ; } catch ( Throwable e ) { // can't log in log routines } } | Tries to close the log . | 98 | 7 |
139,646 | public ApplicationSummary getApplication ( String brooklynId ) throws IOException { Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/v1/applications/" + brooklynId ) . request ( ) . buildGet ( ) ; return invocation . invoke ( ) . readEntity ( ApplicationSummary . class ) ; } | Creates proxied HTTP GET request to Apache Brooklyn which returns the details about a particular hosted application | 76 | 19 |
139,647 | public JsonNode getApplicationsTree ( ) throws IOException { Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/v1/applications/fetch" ) . request ( ) . buildGet ( ) ; return invocation . invoke ( ) . readEntity ( JsonNode . class ) ; } | Creates proxied HTTP GET request to Apache Brooklyn which returns the whole applications tree | 72 | 16 |
139,648 | public TaskSummary removeApplication ( String brooklynId ) throws IOException { Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/v1/applications/" + brooklynId ) . request ( ) . buildDelete ( ) ; return invocation . invoke ( ) . readEntity ( TaskSummary . class ) ; } | Creates a proxied HTTP DELETE request to Apache Brooklyn to remove an application | 76 | 17 |
139,649 | public TaskSummary deployApplication ( String tosca ) throws IOException { Entity content = Entity . entity ( tosca , "application/x-yaml" ) ; Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/v1/applications" ) . request ( ) . buildPost ( content ) ; return invocation . invoke ( ) . readEntity ( TaskSummary . class ) ; } | Creates a proxied HTTP POST request to Apache Brooklyn to deploy a new application | 92 | 16 |
139,650 | public List < EntitySummary > getEntitiesFromApplication ( String brooklynId ) throws IOException { Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/v1/applications/" + brooklynId + "/entities" ) . request ( ) . buildGet ( ) ; return invocation . invoke ( ) . readEntity ( new GenericType < List < EntitySummary > > ( ) { } ) ; } | Creates a proxied HTTP GET request to Apache Brooklyn to retrieve the Application s Entities | 97 | 18 |
139,651 | public PathImpl get ( String scheme ) { ConcurrentHashMap < String , SchemeRoot > map = getMap ( ) ; SchemeRoot root = map . get ( scheme ) ; if ( root == null ) { PathImpl rootPath = createLazyScheme ( scheme ) ; if ( rootPath != null ) { map . putIfAbsent ( scheme , new SchemeRoot ( rootPath ) ) ; root = map . get ( scheme ) ; } } PathImpl path = null ; if ( root != null ) { path = root . getRoot ( ) ; } if ( path != null ) { return path ; } else { return new NotFoundPath ( this , scheme + ":" ) ; } } | Gets the scheme from the schemeMap . | 147 | 9 |
139,652 | public PathImpl remove ( String scheme ) { SchemeRoot oldRoot = getUpdateMap ( ) . remove ( scheme ) ; return oldRoot != null ? oldRoot . getRoot ( ) : null ; } | Removes value from the schemeMap . | 42 | 8 |
139,653 | @ Override public int export ( ConstantPool target ) { int entryIndex = _entry . export ( target ) ; return target . addMethodHandle ( _type , target . getEntry ( entryIndex ) ) . getIndex ( ) ; } | Exports to the target pool . | 50 | 7 |
139,654 | protected void initHttpSystem ( SystemManager system , ServerBartender selfServer ) throws IOException { //RootConfigBoot rootConfig = getRootConfig(); String clusterId = selfServer . getClusterId ( ) ; //ClusterConfigBoot clusterConfig = rootConfig.findCluster(clusterId); String serverHeader = config ( ) . get ( "server.header" ) ; if ( serverHeader != null ) { } else if ( ! CurrentTime . isTest ( ) ) { serverHeader = getProgramName ( ) + "/" + Version . getVersion ( ) ; } else { serverHeader = getProgramName ( ) + "/1.1" ; } // XXX: need cleaner config class names (root vs cluster at minimum) /* ServerContainerConfig serverConfig = new ServerContainerConfig(this, system, selfServer); */ // rootConfig.getProgram().configure(serverConfig); //clusterConfig.getProgram().configure(serverConfig); /* ServerConfig config = new ServerConfig(serverConfig); clusterConfig.getServerDefault().configure(config); ServerConfigBoot serverConfigBoot = rootConfig.findServer(selfServer.getDisplayName()); if (serverConfigBoot != null) { serverConfigBoot.getServerProgram().configure(config); } */ /* _args.getProgram().configure(config); */ // _bootServerConfig.getServerProgram().configure(config); // serverConfig.init(); //int port = getServerPort(); HttpContainerBuilder httpBuilder = createHttpBuilder ( selfServer , serverHeader ) ; // serverConfig.getProgram().configure(httpBuilder); //httpBuilder.init(); //PodSystem.createAndAddSystem(httpBuilder); HttpSystem . createAndAddSystem ( httpBuilder ) ; //return http; } | Configures the selected server from the boot config . | 381 | 10 |
139,655 | @ Override public boolean isModified ( ) { if ( _isDigestModified ) { if ( log . isLoggable ( Level . FINE ) ) log . fine ( _source . getNativePath ( ) + " digest is modified." ) ; return true ; } long sourceLastModified = _source . getLastModified ( ) ; long sourceLength = _source . length ( ) ; // if the source was deleted and we need the source if ( ! _requireSource && sourceLastModified == 0 ) { return false ; } // if the length changed else if ( sourceLength != _length ) { if ( log . isLoggable ( Level . FINE ) ) { log . fine ( _source . getNativePath ( ) + " length is modified (" + _length + " -> " + sourceLength + ")" ) ; } return true ; } // if the source is newer than the old value else if ( sourceLastModified != _lastModified ) { if ( log . isLoggable ( Level . FINE ) ) log . fine ( _source . getNativePath ( ) + " time is modified." ) ; return true ; } else return false ; } | If the source modified date changes at all treat it as a modification . This protects against the case where multiple computers have misaligned dates and a < comparison may fail . | 254 | 33 |
139,656 | public boolean logModified ( Logger log ) { if ( _isDigestModified ) { log . info ( _source . getNativePath ( ) + " digest is modified." ) ; return true ; } long sourceLastModified = _source . getLastModified ( ) ; long sourceLength = _source . length ( ) ; // if the source was deleted and we need the source if ( ! _requireSource && sourceLastModified == 0 ) { return false ; } // if the length changed else if ( sourceLength != _length ) { log . info ( _source . getNativePath ( ) + " length is modified (" + _length + " -> " + sourceLength + ")" ) ; return true ; } // if the source is newer than the old value else if ( sourceLastModified != _lastModified ) { log . info ( _source . getNativePath ( ) + " time is modified." ) ; return true ; } else return false ; } | Log the reason for modification | 207 | 5 |
139,657 | public static BaseType createGenericClass ( Class < ? > type ) { TypeVariable < ? > [ ] typeParam = type . getTypeParameters ( ) ; if ( typeParam == null || typeParam . length == 0 ) return ClassType . create ( type ) ; BaseType [ ] args = new BaseType [ typeParam . length ] ; HashMap < String , BaseType > newParamMap = new HashMap < String , BaseType > ( ) ; String paramDeclName = null ; for ( int i = 0 ; i < args . length ; i ++ ) { args [ i ] = create ( typeParam [ i ] , newParamMap , paramDeclName , ClassFill . TARGET ) ; if ( args [ i ] == null ) { throw new NullPointerException ( "unsupported BaseType: " + type ) ; } newParamMap . put ( typeParam [ i ] . getName ( ) , args [ i ] ) ; } // ioc/07f2 return new GenericParamType ( type , args , newParamMap ) ; } | Create a class - based type where any parameters are filled with the variables not Object . | 218 | 17 |
139,658 | @ Override public int read ( byte [ ] buf , int offset , int length ) throws IOException { if ( buf == null ) throw new NullPointerException ( ) ; else if ( offset < 0 || buf . length < offset + length ) throw new ArrayIndexOutOfBoundsException ( ) ; int result = nativeRead ( _fd , buf , offset , length ) ; if ( result > 0 ) _pos += result ; return result ; } | Reads data from the file . | 95 | 7 |
139,659 | public boolean lock ( boolean shared , boolean block ) { if ( shared && ! _canRead ) { // Invalid request for a shared "read" lock on a write only stream. return false ; } if ( ! shared && ! _canWrite ) { // Invalid request for an exclusive "write" lock on a read only stream. return false ; } return true ; } | Implement LockableStream as a no - op but maintain compatibility with FileWriteStream and FileReadStream wrt returning false to indicate error case . | 76 | 30 |
139,660 | public String getFullName ( ) { StringBuilder name = new StringBuilder ( ) ; name . append ( getName ( ) ) ; name . append ( "(" ) ; JClass [ ] params = getParameterTypes ( ) ; for ( int i = 0 ; i < params . length ; i ++ ) { if ( i != 0 ) name . append ( ", " ) ; name . append ( params [ i ] . getShortName ( ) ) ; } name . append ( ' ' ) ; return name . toString ( ) ; } | Returns a full method name with arguments . | 113 | 8 |
139,661 | @ AfterBatch public void afterBatch ( ) { if ( _isGc ) { return ; } long gcSequence = _gcSequence ; _gcSequence = 0 ; if ( gcSequence <= 0 ) { return ; } try { ArrayList < SegmentHeaderGc > collectList = findCollectList ( gcSequence ) ; if ( collectList . size ( ) < _table . database ( ) . getGcMinCollect ( ) ) { return ; } _gcGeneration ++ ; /* while (collectList.size() > 0) { ArrayList<SegmentHeaderGc> sublist = new ArrayList<>(); // int sublen = Math.min(_db.getGcMinCollect(), collectList.size()); int size = collectList.size(); int sublen = size; if (size > 16) { sublen = Math.min(16, collectList.size() / 2); } // System.out.println("GC: count=" + sublen + " gcSeq=" + gcSequence); //if (_db.getGcMinCollect() <= sublist.size()) { // sublen = Math.max(2, _db.getGcMinCollect() / 2); //} for (int i = 0; i < sublen; i++) { SegmentHeaderGc header = collectList.remove(0); header.startGc(); sublist.add(header); } collect(gcSequence, sublist); } */ collect ( gcSequence , collectList ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } } | GC executes in | 356 | 3 |
139,662 | public URL copyWithDevice ( String deviceAddress , String attrName , String attrValue ) { return new URL ( this . protocol , this . adapterAddress , deviceAddress , Collections . singletonMap ( attrName , attrValue ) , this . serviceUUID , this . characteristicUUID , this . fieldName ) ; } | Makes a copy of a given URL with a new device name and a single attribute . | 71 | 18 |
139,663 | public URL getDeviceURL ( ) { return new URL ( this . protocol , this . adapterAddress , this . deviceAddress , this . deviceAttributes , null , null , null ) ; } | Returns a copy of a given URL truncated to its device component . Service characteristic and field components will be null . | 39 | 23 |
139,664 | public URL getServiceURL ( ) { return new URL ( this . protocol , this . adapterAddress , this . deviceAddress , this . deviceAttributes , this . serviceUUID , null , null ) ; } | Returns a copy of a given URL truncated to its service component . Characteristic and field components will be null . | 43 | 23 |
139,665 | public URL getCharacteristicURL ( ) { return new URL ( this . protocol , this . adapterAddress , this . deviceAddress , this . deviceAttributes , this . serviceUUID , this . characteristicUUID , null ) ; } | Returns a copy of a given URL truncated to its characteristic component . The field component will be null . | 48 | 21 |
139,666 | public URL getParent ( ) { if ( isField ( ) ) { return getCharacteristicURL ( ) ; } else if ( isCharacteristic ( ) ) { return getServiceURL ( ) ; } else if ( isService ( ) ) { return getDeviceURL ( ) ; } else if ( isDevice ( ) ) { return getAdapterURL ( ) ; } else if ( isAdapter ( ) ) { return getProtocolURL ( ) ; } else { return null ; } } | Returns a new URL representing its parent component . | 101 | 9 |
139,667 | public boolean isDescendant ( URL url ) { if ( url . protocol != null && protocol != null && ! protocol . equals ( url . protocol ) ) { return false ; } if ( adapterAddress != null && url . adapterAddress == null ) { return true ; } if ( adapterAddress != null && ! adapterAddress . equals ( url . adapterAddress ) ) { return false ; } if ( deviceAddress != null && url . deviceAddress == null ) { return true ; } if ( deviceAddress != null && ! deviceAddress . equals ( url . deviceAddress ) ) { return false ; } if ( serviceUUID != null && url . serviceUUID == null ) { return true ; } if ( serviceUUID != null ? ! serviceUUID . equals ( url . serviceUUID ) : url . serviceUUID != null ) { return false ; } if ( characteristicUUID != null && url . characteristicUUID == null ) { return true ; } if ( characteristicUUID != null ? ! characteristicUUID . equals ( url . characteristicUUID ) : url . characteristicUUID != null ) { return false ; } return fieldName != null && url . fieldName == null ; } | Checks whether the URL is a descendant of a URL provided as an argument . If the provided URL does not specify protocol then it will match any protocol of the URL | 249 | 33 |
139,668 | public Object putValue ( String key , Object value ) { return _valueMap . put ( key , value ) ; } | Sets a value . | 25 | 5 |
139,669 | static JavaAnnotation [ ] parseAnnotations ( InputStream is , ConstantPool cp , JavaClassLoader loader ) throws IOException { int n = readShort ( is ) ; JavaAnnotation [ ] annArray = new JavaAnnotation [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { annArray [ i ] = parseAnnotation ( is , cp , loader ) ; } return annArray ; } | Parses the annotation from an annotation block . | 90 | 10 |
139,670 | @ Override public void run ( ) { try { handleAlarm ( ) ; } catch ( Throwable e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } finally { _isRunning = false ; _runningAlarmCount . decrementAndGet ( ) ; } } | Runs the alarm . This is only called from the worker thread . | 67 | 14 |
139,671 | private void handleAlarm ( ) { AlarmListener listener = getListener ( ) ; if ( listener == null ) { return ; } Thread thread = Thread . currentThread ( ) ; ClassLoader loader = getContextLoader ( ) ; if ( loader != null ) { thread . setContextClassLoader ( loader ) ; } else { thread . setContextClassLoader ( _systemLoader ) ; } try { listener . handleAlarm ( this ) ; } finally { thread . setContextClassLoader ( _systemLoader ) ; } } | Handles the alarm . | 109 | 5 |
139,672 | private IDomain createDomainIfNotExist ( String domainId ) { IDomain foundDomain = findDomainByID ( domainId ) ; if ( foundDomain == null ) { foundDomain = user . createDomain ( domainName ) ; } return foundDomain ; } | This method checks if the domain exists for the user . If the domain was not found it will be created using the domainId . | 57 | 26 |
139,673 | protected void configureEnv ( ) { //TODO a sensor with the custom-environment variables? Map < String , String > envs = getEntity ( ) . getConfig ( OpenShiftWebApp . ENV ) ; if ( ( envs != null ) && ( envs . size ( ) != 0 ) ) { deployedApp . addEnvironmentVariables ( envs ) ; deployedApp . restart ( ) ; } } | Add the env tot he application | 89 | 6 |
139,674 | @ Override public void shutdown ( DeployService2Impl < I > deploy , ShutdownModeAmp mode , Result < Boolean > result ) { deploy . shutdownImpl ( mode , result ) ; } | Stops the instance from an admin command . | 40 | 9 |
139,675 | public JavaClass readFromClassPath ( String classFile ) throws IOException { Thread thread = Thread . currentThread ( ) ; ClassLoader loader = thread . getContextClassLoader ( ) ; InputStream is = loader . getResourceAsStream ( classFile ) ; try { return parse ( is ) ; } finally { is . close ( ) ; } } | Reads the class from the classpath . | 73 | 9 |
139,676 | private void updateLocalRepository ( ) throws GitAPIException { try { Git . open ( new File ( paasifyRepositoryDirecory ) ) . pull ( ) . call ( ) ; } catch ( IOException e ) { log . error ( "Cannot update local Git repository" ) ; log . error ( e . getMessage ( ) ) ; } } | Updates local Paasify repository | 78 | 7 |
139,677 | private Offering getOfferingFromJSON ( JSONObject obj ) throws IOException { JSONArray infrastructures = ( JSONArray ) obj . get ( "infrastructures" ) ; String name = ( String ) obj . get ( "name" ) ; Offering offering = null ; if ( infrastructures == null || infrastructures . size ( ) == 0 ) { String providerName = Offering . sanitizeName ( name ) ; offering = this . parseOffering ( providerName , providerName , obj ) ; } else { for ( Object element : infrastructures ) { JSONObject infrastructure = ( JSONObject ) element ; String continent = "" ; String country = "" ; String fullName = name ; if ( infrastructure . containsKey ( "continent" ) ) { continent = infrastructure . get ( "continent" ) . toString ( ) ; if ( ! continent . isEmpty ( ) ) { continent = continentFullName . get ( continent ) ; fullName = fullName + "." + continent ; } } if ( infrastructure . containsKey ( "country" ) ) { country = infrastructure . get ( "country" ) . toString ( ) ; if ( ! country . isEmpty ( ) ) fullName = fullName + "." + country ; } String providerName = Offering . sanitizeName ( name ) ; String offeringName = Offering . sanitizeName ( fullName ) ; offering = this . parseOffering ( providerName , offeringName , obj ) ; if ( ! continent . isEmpty ( ) ) offering . addProperty ( "continent" , continent ) ; if ( ! country . isEmpty ( ) ) offering . addProperty ( "country" , country ) ; } } return offering ; } | Conversion from Paasify JSON model into TOSCA PaaS model | 370 | 16 |
139,678 | @ Override public int acceptInitialRead ( byte [ ] buffer , int offset , int length ) { synchronized ( _readLock ) { // initialize fields from the _fd int result = nativeAcceptInit ( _socketFd , _localAddrBuffer , _remoteAddrBuffer , buffer , offset , length ) ; return result ; } } | Initialize new connection from the socket . | 71 | 8 |
139,679 | @ Override public String getRemoteHost ( ) { if ( _remoteName == null ) { byte [ ] remoteAddrBuffer = _remoteAddrBuffer ; char [ ] remoteAddrCharBuffer = _remoteAddrCharBuffer ; if ( _remoteAddrLength <= 0 ) { _remoteAddrLength = InetAddressUtil . createIpAddress ( remoteAddrBuffer , remoteAddrCharBuffer ) ; } _remoteName = new String ( remoteAddrCharBuffer , 0 , _remoteAddrLength ) ; } return _remoteName ; } | Returns the remote client s host name . | 120 | 8 |
139,680 | @ Override public String getLocalHost ( ) { if ( _localName == null ) { byte [ ] localAddrBuffer = _localAddrBuffer ; char [ ] localAddrCharBuffer = _localAddrCharBuffer ; if ( _localAddrLength <= 0 ) { _localAddrLength = InetAddressUtil . createIpAddress ( localAddrBuffer , localAddrCharBuffer ) ; } _localName = new String ( localAddrCharBuffer , 0 , _localAddrLength ) ; } return _localName ; } | Returns the local server s host name . | 120 | 8 |
139,681 | public int read ( byte [ ] buffer , int offset , int length , long timeout ) throws IOException { if ( length == 0 ) { throw new IllegalArgumentException ( ) ; } long requestExpireTime = _requestExpireTime ; if ( requestExpireTime > 0 && requestExpireTime < CurrentTime . currentTime ( ) ) { close ( ) ; throw new ClientDisconnectException ( L . l ( "{0}: request-timeout read" , addressRemote ( ) ) ) ; } int result = 0 ; synchronized ( _readLock ) { long now = CurrentTime . getCurrentTimeActual ( ) ; long expires ; // gap is because getCurrentTimeActual() isn't exact long gap = 20 ; if ( timeout >= 0 ) expires = timeout + now - gap ; else expires = _socketTimeout + now - gap ; do { result = readNative ( _socketFd , buffer , offset , length , timeout ) ; now = CurrentTime . getCurrentTimeActual ( ) ; timeout = expires - now ; } while ( result == JniStream . TIMEOUT_EXN && timeout > 0 ) ; } return result ; } | Reads from the socket . | 243 | 6 |
139,682 | public int write ( byte [ ] buffer , int offset , int length , boolean isEnd ) throws IOException { int result ; long requestExpireTime = _requestExpireTime ; if ( requestExpireTime > 0 && requestExpireTime < CurrentTime . currentTime ( ) ) { close ( ) ; throw new ClientDisconnectException ( L . l ( "{0}: request-timeout write exp={0}s" , addressRemote ( ) , CurrentTime . currentTime ( ) - requestExpireTime ) ) ; } synchronized ( _writeLock ) { long now = CurrentTime . getCurrentTimeActual ( ) ; long expires = _socketTimeout + now ; // _isNativeFlushRequired = true; do { result = writeNative ( _socketFd , buffer , offset , length ) ; //byte []tempBuffer = _byteBuffer.array(); //System.out.println("TEMP: " + tempBuffer); //System.arraycopy(buffer, offset, tempBuffer, 0, length); //_byteBuffer.position(0); //_byteBuffer.put(buffer, offset, length); //result = writeNativeNio(_fd, _byteBuffer, 0, length); } while ( result == JniStream . TIMEOUT_EXN && CurrentTime . getCurrentTimeActual ( ) < expires ) ; } if ( isEnd ) { // websocket/1261 closeWrite ( ) ; } return result ; } | Writes to the socket . | 306 | 6 |
139,683 | @ Override public StreamImpl stream ( ) throws IOException { if ( _stream == null ) { _stream = new JniStream ( this ) ; } _stream . init ( ) ; return _stream ; } | Returns a stream impl for the socket encapsulating the input and output stream . | 45 | 15 |
139,684 | private boolean onLoad ( Cursor cursor , T entity ) { if ( cursor == null ) { if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( L . l ( "{0} load returned null" , _entityInfo ) ) ; } _entityInfo . loadFail ( entity ) ; return false ; } else { _entityInfo . load ( cursor , entity ) ; if ( log . isLoggable ( Level . FINER ) ) { log . finer ( "loaded " + entity ) ; } return true ; } } | Fills the entity on load complete . | 119 | 8 |
139,685 | @ Override public void findOne ( String sql , Object [ ] params , Result < Cursor > result ) { _db . findOne ( sql , result , params ) ; } | Finds a single value returning a cursor . | 38 | 9 |
139,686 | @ Override public void findAll ( String sql , Object [ ] params , Result < Iterable < Cursor > > result ) { _db . findAll ( sql , result , params ) ; } | Finds a list of values returning a list of cursors | 42 | 12 |
139,687 | public < V > Function < Cursor , V > cursorToBean ( Class < V > api ) { return ( FindDataVault < ID , T , V > ) _valueBeans . get ( api ) ; } | Extract a bean from a cursor . | 48 | 8 |
139,688 | public static TempCharBuffer allocate ( ) { TempCharBuffer next = _freeList . allocate ( ) ; if ( next == null ) return new TempCharBuffer ( SIZE ) ; next . _next = null ; next . _offset = 0 ; next . _length = 0 ; next . _bufferCount = 0 ; return next ; } | Allocate a TempCharBuffer reusing one if available . | 71 | 12 |
139,689 | public static void free ( TempCharBuffer buf ) { buf . _next = null ; if ( buf . _buf . length == SIZE ) _freeList . free ( buf ) ; } | Frees a single buffer . | 40 | 6 |
139,690 | @ Override public void log ( int level , String message ) { switch ( level ) { case LogChute . WARN_ID : log . warn ( message ) ; break ; case LogChute . INFO_ID : log . info ( message ) ; break ; case LogChute . TRACE_ID : log . trace ( message ) ; break ; case LogChute . ERROR_ID : log . error ( message ) ; break ; case LogChute . DEBUG_ID : default : log . debug ( message ) ; break ; } } | Send a log message from Velocity . | 114 | 7 |
139,691 | @ Override public boolean isLevelEnabled ( int level ) { switch ( level ) { case LogChute . DEBUG_ID : return log . isDebugEnabled ( ) ; case LogChute . INFO_ID : return log . isInfoEnabled ( ) ; case LogChute . TRACE_ID : return log . isTraceEnabled ( ) ; case LogChute . WARN_ID : return log . isWarnEnabled ( ) ; case LogChute . ERROR_ID : return log . isErrorEnabled ( ) ; default : return true ; } } | Checks whether the specified log level is enabled . | 118 | 10 |
139,692 | @ Override public void onPut ( byte [ ] key , TypePut type ) { //_watchKey.init(key); WatchKey watchKey = new WatchKey ( key ) ; switch ( type ) { case LOCAL : ArrayList < WatchEntry > listLocal = _entryMapLocal . get ( watchKey ) ; onPut ( listLocal , key ) ; break ; case REMOTE : { int hash = _table . getPodHash ( key ) ; TablePodNodeAmp node = _table . getTablePod ( ) . getNode ( hash ) ; if ( node . isSelfCopy ( ) ) { // copies are responsible for their own local watch events onPut ( key , TypePut . LOCAL ) ; } if ( node . isSelfOwner ( ) ) { // only the owner sends remote watch events /* System.out.println("NSO: " + BartenderSystem.getCurrentSelfServer().getDisplayName() + " " + node.isSelfOwner() + " " + node + " " + Hex.toHex(key)); */ ArrayList < WatchEntry > listRemote = _entryMapRemote . get ( watchKey ) ; onPut ( listRemote , key ) ; } break ; } default : throw new IllegalArgumentException ( String . valueOf ( type ) ) ; } } | Notification on a table put . | 278 | 7 |
139,693 | private void onPut ( ArrayList < WatchEntry > list , byte [ ] key ) { if ( list != null ) { int size = list . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { WatchEntry entry = list . get ( i ) ; RowCursor rowCursor = _table . cursor ( ) ; rowCursor . setKey ( key , 0 ) ; EnvKelp envKelp = null ; CursorKraken cursor = new CursorKraken ( table ( ) , envKelp , rowCursor , _results ) ; entry . onPut ( cursor ) ; } } } | Notify all watches with the updated row for the given key . | 141 | 13 |
139,694 | @ Override public long skip ( long n ) throws IOException { if ( _is == null ) { if ( _s == null ) return - 1 ; _is = _s . getInputStream ( ) ; } return _is . skip ( n ) ; } | Skips bytes in the file . | 56 | 7 |
139,695 | @ Override public int getAvailable ( ) throws IOException { if ( _is == null ) { if ( _s == null ) return - 1 ; _is = _s . getInputStream ( ) ; } return _is . available ( ) ; } | Returns the number of bytes available to be read from the input stream . | 54 | 14 |
139,696 | @ Override public void flush ( ) throws IOException { if ( _os == null || ! _needsFlush ) return ; _needsFlush = false ; try { _os . flush ( ) ; } catch ( IOException e ) { try { close ( ) ; } catch ( IOException e1 ) { } throw ClientDisconnectException . create ( e ) ; } } | Flushes the socket . | 80 | 5 |
139,697 | @ Override public int available ( ) throws IOException { if ( _readOffset < _readLength ) { return _readLength - _readOffset ; } StreamImpl source = _source ; if ( source != null ) { return source . getAvailable ( ) ; } else { return - 1 ; } } | Returns an estimate of the available bytes . If a read would not block it will always return greater than 0 . | 64 | 22 |
139,698 | @ Override public synchronized boolean addLogger ( Logger logger ) { EnvironmentLogger envLogger = addLogger ( logger . getName ( ) , logger . getResourceBundleName ( ) ) ; // handle custom logger if ( ! logger . getClass ( ) . equals ( Logger . class ) ) { return envLogger . addCustomLogger ( logger ) ; } return false ; } | Adds a logger . | 85 | 4 |
139,699 | private EnvironmentLogger buildParentTree ( String childName ) { if ( childName == null || childName . equals ( "" ) ) return null ; int p = childName . lastIndexOf ( ' ' ) ; String parentName ; if ( p > 0 ) parentName = childName . substring ( 0 , p ) ; else parentName = "" ; EnvironmentLogger parent = null ; SoftReference < EnvironmentLogger > parentRef = _envLoggers . get ( parentName ) ; if ( parentRef != null ) parent = parentRef . get ( ) ; if ( parent != null ) return parent ; else { parent = new EnvironmentLogger ( parentName , null ) ; _envLoggers . put ( parentName , new SoftReference < EnvironmentLogger > ( parent ) ) ; EnvironmentLogger grandparent = buildParentTree ( parentName ) ; if ( grandparent != null ) parent . setParent ( grandparent ) ; return parent ; } } | Recursively builds the parents of the logger . | 201 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.