idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
139,300
public String printISO8601 ( ) { StringBuilder sb = new StringBuilder ( ) ; if ( _year > 0 ) { sb . append ( ( _year / 1000 ) % 10 ) ; sb . append ( ( _year / 100 ) % 10 ) ; sb . append ( ( _year / 10 ) % 10 ) ; sb . append ( _year % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( ( _month + 1 ) / 10 ) % 10 ) ; sb . append ( ( _month + 1 ) % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( ( _dayOfMonth + 1 ) / 10 ) % 10 ) ; sb . append ( ( _dayOfMonth + 1 ) % 10 ) ; } long time = _timeOfDay / 1000 ; long ms = _timeOfDay % 1000 ; sb . append ( ' ' ) ; sb . append ( ( time / 36000 ) % 10 ) ; sb . append ( ( time / 3600 ) % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( time / 600 ) % 6 ) ; sb . append ( ( time / 60 ) % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( time / 10 ) % 6 ) ; sb . append ( ( time / 1 ) % 10 ) ; if ( ms != 0 ) { sb . append ( ' ' ) ; sb . append ( ( ms / 100 ) % 10 ) ; sb . append ( ( ms / 10 ) % 10 ) ; sb . append ( ms % 10 ) ; } if ( _zoneName == null ) { sb . append ( "Z" ) ; return sb . toString ( ) ; } // server/1471 - XXX: was commented out long offset = _zoneOffset ; if ( offset < 0 ) { sb . append ( "-" ) ; offset = - offset ; } else sb . append ( "+" ) ; sb . append ( ( offset / 36000000 ) % 10 ) ; sb . append ( ( offset / 3600000 ) % 10 ) ; sb . append ( ' ' ) ; sb . append ( ( offset / 600000 ) % 6 ) ; sb . append ( ( offset / 60000 ) % 10 ) ; return sb . toString ( ) ; }
Prints the time in ISO 8601
521
8
139,301
public String printISO8601Date ( ) { CharBuffer cb = new CharBuffer ( ) ; if ( _year > 0 ) { cb . append ( ( _year / 1000 ) % 10 ) ; cb . append ( ( _year / 100 ) % 10 ) ; cb . append ( ( _year / 10 ) % 10 ) ; cb . append ( _year % 10 ) ; cb . append ( ' ' ) ; cb . append ( ( ( _month + 1 ) / 10 ) % 10 ) ; cb . append ( ( _month + 1 ) % 10 ) ; cb . append ( ' ' ) ; cb . append ( ( ( _dayOfMonth + 1 ) / 10 ) % 10 ) ; cb . append ( ( _dayOfMonth + 1 ) % 10 ) ; } return cb . toString ( ) ; }
Prints just the date component of ISO 8601
186
10
139,302
public synchronized static String formatGMT ( long gmtTime , String format ) { _gmtDate . setGMTTime ( gmtTime ) ; return _gmtDate . format ( new CharBuffer ( ) , format ) . toString ( ) ; }
Formats a date .
53
5
139,303
public String format ( String format ) { CharBuffer cb = new CharBuffer ( ) ; return format ( cb , format ) . close ( ) ; }
Formats the current date .
33
6
139,304
private long yearToDayOfEpoch ( long year ) { if ( year > 0 ) { year -= 1601 ; return ( 365 * year + year / 4 - year / 100 + year / 400 - ( ( 1970 - 1601 ) * 365 + ( 1970 - 1601 ) / 4 - 3 ) ) ; } else { year = 2000 - year ; return ( ( 2000 - 1970 ) * 365 + ( 2000 - 1970 ) / 4 - ( 365 * year + year / 4 - year / 100 + year / 400 ) ) ; } }
Based on the year return the number of days since the epoch .
114
13
139,305
private long monthToDayOfYear ( long month , boolean isLeapYear ) { long day = 0 ; for ( int i = 0 ; i < month && i < 12 ; i ++ ) { day += DAYS_IN_MONTH [ i ] ; if ( i == 1 && isLeapYear ) day ++ ; } return day ; }
Calculates the day of the year for the beginning of the month .
74
15
139,306
public long setDate ( long year , long month , long day ) { year += ( long ) Math . floor ( month / 12.0 ) ; month -= ( long ) 12 * Math . floor ( month / 12.0 ) ; _year = year ; _month = month ; _dayOfMonth = day - 1 ; calculateJoin ( ) ; calculateSplit ( _localTimeOfEpoch ) ; return _localTimeOfEpoch ; }
Sets date in the local time .
93
8
139,307
private void calculateSplit ( long localTime ) { _localTimeOfEpoch = localTime ; _dayOfEpoch = divFloor ( _localTimeOfEpoch , MS_PER_DAY ) ; _timeOfDay = _localTimeOfEpoch - MS_PER_DAY * _dayOfEpoch ; calculateYear ( ) ; calculateMonth ( ) ; _hour = _timeOfDay / 3600000 ; _minute = _timeOfDay / 60000 % 60 ; _second = _timeOfDay / 1000 % 60 ; _ms = _timeOfDay % 1000 ; if ( _timeZone == _gmtTimeZone ) { _isDaylightTime = false ; _zoneName = _stdName ; _zoneOffset = 0 ; } else { // server/1470 long tempOffset = _timeZone . getOffset ( _localTimeOfEpoch ) ; _zoneOffset = _timeZone . getOffset ( _localTimeOfEpoch - tempOffset ) ; if ( _zoneOffset == _timeZone . getRawOffset ( ) ) { _isDaylightTime = false ; _zoneName = _stdName ; } else { _isDaylightTime = true ; _zoneName = _dstName ; } } _calendar . setTimeInMillis ( _localTimeOfEpoch ) ; }
Calculate and set the calendar components based on the given time .
282
14
139,308
private void calculateYear ( ) { long days = _dayOfEpoch ; // shift to using 1601 as a base days += ( 1970 - 1601 ) * 365 + ( 1970 - 1601 ) / 4 - 3 ; long n400 = divFloor ( days , 400 * 365 + 100 - 3 ) ; days -= n400 * ( 400 * 365 + 100 - 3 ) ; long n100 = divFloor ( days , 100 * 365 + 25 - 1 ) ; if ( n100 == 4 ) n100 = 3 ; days -= n100 * ( 100 * 365 + 25 - 1 ) ; long n4 = divFloor ( days , 4 * 365 + 1 ) ; if ( n4 == 25 ) n4 = 24 ; days -= n4 * ( 4 * 365 + 1 ) ; long n1 = divFloor ( days , 365 ) ; if ( n1 == 4 ) n1 = 3 ; _year = 400 * n400 + 100 * n100 + 4 * n4 + n1 + 1601 ; _dayOfYear = ( int ) ( days - 365 * n1 ) ; _isLeapYear = isLeapYear ( _year ) ; }
Calculates the year the dayOfYear and whether this is a leap year from the current days since the epoch .
251
24
139,309
private void calculateMonth ( ) { _dayOfMonth = _dayOfYear ; for ( _month = 0 ; _month < 12 ; _month ++ ) { if ( _month == 1 && _isLeapYear ) { if ( _dayOfMonth < 29 ) return ; else _dayOfMonth -= 29 ; } else if ( _dayOfMonth < DAYS_IN_MONTH [ ( int ) _month ] ) return ; else _dayOfMonth -= DAYS_IN_MONTH [ ( int ) _month ] ; } }
Calculates the month based on the day of the year .
116
13
139,310
private long calculateJoin ( ) { _year += divFloor ( _month , 12 ) ; _month -= 12 * divFloor ( _month , 12 ) ; _localTimeOfEpoch = MS_PER_DAY * ( yearToDayOfEpoch ( _year ) + monthToDayOfYear ( _month , isLeapYear ( _year ) ) + _dayOfMonth ) ; _localTimeOfEpoch += _ms + 1000 * ( _second + 60 * ( _minute + 60 * _hour ) ) ; return _localTimeOfEpoch ; }
Based on the current data calculate the time since the epoch .
123
12
139,311
public boolean logModified ( Logger log ) { for ( int i = _dependencyList . size ( ) - 1 ; i >= 0 ; i -- ) { Dependency dependency = _dependencyList . get ( i ) ; if ( dependency . logModified ( log ) ) return true ; } return false ; }
Log the reason for the modification
68
6
139,312
@ Override public void getSafe ( RowCursor cursor , Result < Boolean > result ) { result . ok ( getImpl ( cursor ) ) ; }
Non - peek get .
32
5
139,313
@ Direct @ Override public void getStream ( RowCursor cursor , Result < GetStreamResult > result ) { long version = cursor . getVersion ( ) ; PageLeafImpl leaf = getLeafByCursor ( cursor ) ; if ( leaf == null ) { result . ok ( new GetStreamResult ( false , null ) ) ; return ; } if ( ! leaf . get ( cursor ) ) { result . ok ( new GetStreamResult ( false , null ) ) ; return ; } if ( version == cursor . getVersion ( ) ) { result . ok ( new GetStreamResult ( true , null ) ) ; return ; } StreamSource ss = leaf . getStream ( cursor , this ) ; boolean isFound = ss != null ; result . ok ( new GetStreamResult ( isFound , ss ) ) ; }
For cluster calls returns a stream to the new value if the value has changed .
173
16
139,314
long getSequenceSize ( SegmentKelp segment ) { int tailPid = _tailPid . get ( ) ; long size = 0 ; for ( int i = 0 ; i <= tailPid ; i ++ ) { Page page = _pages . get ( i ) ; if ( page != null && page . getSegment ( ) == segment ) { size += page . size ( ) ; } } return size ; }
Returns the size in bytes of all pages with the given sequence .
92
13
139,315
@ Override public void checkpoint ( Result < Boolean > result ) { if ( ! _journalStream . saveStart ( ) ) { result . ok ( true ) ; return ; } TableWriterService readWrite = _table . getReadWrite ( ) ; // long limit = Integer.MAX_VALUE; // 128 int tailPid = _tailPid . get ( ) ; for ( int pid = 1 ; pid <= tailPid ; pid ++ ) { Page page = _pages . get ( pid ) ; if ( page != null ) { page . write ( _table , this , readWrite ) ; } } readWrite . fsync ( new CheckpointResult ( result ) ) ; }
Requests a checkpoint flushing the in - memory data to disk .
144
14
139,316
boolean compareAndSetLeaf ( Page oldPage , Page page ) { if ( oldPage == page ) { return true ; } int pid = ( int ) page . getId ( ) ; updateTailPid ( pid ) ; if ( oldPage instanceof PageLeafImpl && page instanceof PageLeafImpl ) { PageLeafImpl oldLeaf = ( PageLeafImpl ) oldPage ; PageLeafImpl newLeaf = ( PageLeafImpl ) page ; if ( BlockTree . compareKey ( oldLeaf . getMaxKey ( ) , newLeaf . getMaxKey ( ) , 0 ) < 0 ) { System . err . println ( " DERP: " + oldPage + " " + page ) ; Thread . dumpStack ( ) ; /* throw new IllegalStateException("DERP: old=" + oldPage + " " + page + " old-dirt:" + oldPage.isDirty()); */ } } boolean result = _pages . compareAndSet ( pid , oldPage , page ) ; return result ; }
Updates the leaf to a new page . Called only from TableService .
226
15
139,317
public static DynamicClassLoader getDynamicClassLoader ( ClassLoader loader ) { for ( ; loader != null ; loader = loader . getParent ( ) ) { if ( loader instanceof DynamicClassLoader ) { return ( DynamicClassLoader ) loader ; } } return null ; }
Returns the topmost dynamic class loader .
56
8
139,318
public static void setConfigException ( Throwable e ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; for ( ; loader != null ; loader = loader . getParent ( ) ) { if ( loader instanceof EnvironmentClassLoader ) { EnvironmentClassLoader envLoader = ( EnvironmentClassLoader ) loader ; envLoader . setConfigException ( e ) ; return ; } } }
Sets a configuration exception .
85
6
139,319
public static Throwable getConfigException ( ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; for ( ; loader != null ; loader = loader . getParent ( ) ) { if ( loader instanceof EnvironmentClassLoader ) { EnvironmentClassLoader envLoader = ( EnvironmentClassLoader ) loader ; if ( envLoader . getConfigException ( ) != null ) return envLoader . getConfigException ( ) ; } } return null ; }
Returns any configuration exception .
97
5
139,320
public static String getLocalClassPath ( ClassLoader loader ) { for ( ; loader != null ; loader = loader . getParent ( ) ) { if ( loader instanceof EnvironmentClassLoader ) { return ( ( EnvironmentClassLoader ) loader ) . getLocalClassPath ( ) ; } } return DynamicClassLoader . getSystemClassPath ( ) ; }
Returns the classpath for the environment level .
72
9
139,321
public static void closeGlobal ( ) { ArrayList < EnvLoaderListener > listeners ; listeners = new ArrayList <> ( ) ; listeners . addAll ( _globalLoaderListeners ) ; _globalLoaderListeners . clear ( ) ; for ( int i = 0 ; i < listeners . size ( ) ; i ++ ) { EnvLoaderListener listener = listeners . get ( i ) ; listener . classLoaderDestroy ( null ) ; } }
destroys the current environment .
93
7
139,322
public static synchronized void initializeEnvironment ( ) { if ( _isStaticInit ) return ; _isStaticInit = true ; ClassLoader systemLoader = ClassLoader . getSystemClassLoader ( ) ; Thread thread = Thread . currentThread ( ) ; ClassLoader oldLoader = thread . getContextClassLoader ( ) ; try { thread . setContextClassLoader ( systemLoader ) ; if ( "1.8." . compareTo ( System . getProperty ( "java.runtime.version" ) ) > 0 ) throw new ConfigException ( "Baratine requires JDK 1.8 or later" ) ; // #2281 // PolicyImpl.init(); //EnvironmentStream.setStdout(System.out); //EnvironmentStream.setStderr(System.err); /* try { Vfs.initJNI(); } catch (Throwable e) { } */ Properties props = System . getProperties ( ) ; ClassLoader envClassLoader = EnvironmentClassLoader . class . getClassLoader ( ) ; /* boolean isGlobalLoadableJndi = false; try { Class<?> cl = Class.forName("com.caucho.v5.naming.InitialContextFactoryImpl", false, systemLoader); isGlobalLoadableJndi = (cl != null); } catch (Exception e) { log().log(Level.FINER, e.toString(), e); } // #3486 String namingPkgs = (String) props.get("java.naming.factory.url.pkgs"); if (namingPkgs == null) namingPkgs = "com.caucho.v5.naming"; else namingPkgs = namingPkgs + ":" + "com.caucho.v5.naming"; props.put("java.naming.factory.url.pkgs", namingPkgs); if (isGlobalLoadableJndi) { // These properties require the server to be at the system loader if (props.get("java.naming.factory.initial") == null) { props.put("java.naming.factory.initial", "com.caucho.v5.naming.InitialContextFactoryImpl"); } } */ /* boolean isGlobalLoadableJmx = false; try { Class<?> cl = Class.forName("com.caucho.v5.jmx.MBeanServerBuilderImpl", false, systemLoader); isGlobalLoadableJmx = (cl != null); } catch (Exception e) { log().log(Level.FINER, e.toString(), e); } if (isGlobalLoadableJmx) { // props.put("java.naming.factory.url.pkgs", "com.caucho.naming"); EnvironmentProperties.enableEnvironmentSystemProperties(true); String oldBuilder = props.getProperty("javax.management.builder.initial"); if (oldBuilder == null) { oldBuilder = "com.caucho.v5.jmx.MBeanServerBuilderImpl"; props.put("javax.management.builder.initial", oldBuilder); } Object value = ManagementFactory.getPlatformMBeanServer(); } */ } catch ( Throwable e ) { log ( ) . log ( Level . FINE , e . toString ( ) , e ) ; } finally { thread . setContextClassLoader ( oldLoader ) ; _isInitComplete = true ; } }
Initializes the environment
747
4
139,323
private MonitoringRule buildRelatedRule ( IGuaranteeTerm guarantee ) { MonitoringRule result = new MonitoringRule ( ) ; result . setId ( guarantee . getName ( ) ) ; String violation = extractOutputMetric ( guarantee ) ; Parameter param = new Parameter ( ) ; param . setName ( QosModels . METRIC_PARAM_NAME ) ; param . setValue ( violation ) ; Action action = new Action ( ) ; action . setName ( QosModels . OUTPUT_METRIC_ACTION ) ; action . getParameters ( ) . add ( param ) ; Actions actions = new Actions ( ) ; actions . getActions ( ) . add ( action ) ; result . setActions ( actions ) ; return result ; }
Build a MonitoringRule given a guarantee term
159
8
139,324
public void debug ( WriteStream out , Path path , byte [ ] tableKey ) throws IOException { SegmentKelpBuilder builder = new SegmentKelpBuilder ( ) ; builder . path ( path ) ; builder . create ( false ) ; builder . services ( ServicesAmp . newManager ( ) . get ( ) ) ; SegmentServiceImpl segmentService = builder . build ( ) ; for ( SegmentExtent extent : segmentService . getSegmentExtents ( ) ) { debugSegment ( out , segmentService , extent , tableKey ) ; } }
Debug with a table key
121
5
139,325
private void debugSegment ( WriteStream out , SegmentServiceImpl segmentService , SegmentExtent extent , byte [ ] debugTableKey ) throws IOException { int length = extent . length ( ) ; try ( InSegment in = segmentService . openRead ( extent ) ) { ReadStream is = new ReadStream ( in ) ; is . position ( length - BLOCK_SIZE ) ; long seq = BitsUtil . readLong ( is ) ; if ( seq <= 0 ) { return ; } byte [ ] tableKey = new byte [ 32 ] ; is . readAll ( tableKey , 0 , tableKey . length ) ; TableEntry table = segmentService . findTable ( tableKey ) ; if ( table == null ) { return ; } if ( debugTableKey != null && ! Arrays . equals ( debugTableKey , tableKey ) ) { return ; } out . println ( ) ; StringBuilder sb = new StringBuilder ( ) ; Base64Util . encode ( sb , seq ) ; long time = _idGen . time ( seq ) ; out . println ( "Segment: " + extent . getId ( ) + " (seq: " + sb + ", table: " + Hex . toShortHex ( tableKey ) + ", addr: 0x" + Long . toHexString ( extent . address ( ) ) + ", len: 0x" + Integer . toHexString ( length ) + ", time: " + LocalDateTime . ofEpochSecond ( time / 1000 , 0 , ZoneOffset . UTC ) + ")" ) ; debugSegmentEntries ( out , is , extent , table ) ; } }
Trace through a segment displaying its sequence table and extent .
353
12
139,326
private void debugSegmentEntries ( WriteStream out , ReadStream is , SegmentExtent extent , TableEntry table ) throws IOException { TempBuffer tBuf = TempBuffer . create ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; for ( long ptr = extent . length ( ) - BLOCK_SIZE ; ptr > 0 ; ptr -= BLOCK_SIZE ) { is . position ( ptr ) ; is . readAll ( buffer , 0 , BLOCK_SIZE ) ; long seq = BitsUtil . readLong ( buffer , 0 ) ; int head = 8 ; byte [ ] tableKey = new byte [ 32 ] ; System . arraycopy ( buffer , head , tableKey , 0 , tableKey . length ) ; is . readAll ( tableKey , 0 , tableKey . length ) ; head += tableKey . length ; int offset = BLOCK_SIZE - 8 ; int tail = BitsUtil . readInt16 ( buffer , offset ) ; offset += 2 ; boolean isCont = buffer [ offset ] == 1 ; if ( seq <= 0 || tail <= 0 ) { return ; } while ( ( head = debugSegmentIndex ( out , is , buffer , extent . address ( ) , ptr , head , table ) ) < tail ) { } if ( ! isCont ) { break ; } } }
Trace through the segment entries .
282
7
139,327
private int debugSegmentIndex ( WriteStream out , ReadStream is , byte [ ] buffer , long segmentAddress , long ptr , int head , TableEntry table ) throws IOException { int sublen = 1 + 4 * 4 ; //tail -= sublen; // is.position(ptr + tail); int typeCode = buffer [ head ] & 0xff ; head ++ ; if ( typeCode <= 0 ) { return 0 ; } Type type = Type . valueOf ( typeCode ) ; int pid = BitsUtil . readInt ( buffer , head ) ; head += 4 ; int nextPid = BitsUtil . readInt ( buffer , head ) ; head += 4 ; int offset = BitsUtil . readInt ( buffer , head ) ; head += 4 ; int length = BitsUtil . readInt ( buffer , head ) ; head += 4 ; switch ( type ) { case LEAF : out . print ( " " + type ) ; debugLeaf ( out , is , segmentAddress , offset , table ) ; break ; case LEAF_DELTA : out . print ( " " + type ) ; break ; case BLOB : case BLOB_FREE : out . print ( " " + type ) ; break ; default : out . print ( " unk(" + type + ")" ) ; break ; } // is.position(pos); out . println ( " pid:" + pid + " next:" + nextPid + " offset:" + offset + " length:" + length ) ; return head ; }
Debug a single segment index entry .
321
7
139,328
public void addMergePath ( PathImpl path ) { if ( ! ( path instanceof MergePath ) ) { // Need to normalize so directory paths ends with a "./" // XXX: //if (path.isDirectory()) // path = path.lookup("./"); ArrayList < PathImpl > pathList = ( ( MergePath ) _root ) . _pathList ; if ( ! pathList . contains ( path ) ) pathList . add ( path ) ; } else if ( ( ( MergePath ) path ) . _root == _root ) return ; else { MergePath mergePath = ( MergePath ) path ; ArrayList < PathImpl > subPaths = mergePath . getMergePaths ( ) ; String pathName = "./" + mergePath . _pathname + "/" ; for ( int i = 0 ; i < subPaths . size ( ) ; i ++ ) { PathImpl subPath = subPaths . get ( i ) ; addMergePath ( subPath . lookup ( pathName ) ) ; } } }
Adds a new path to the end of the merge path .
226
12
139,329
public PathImpl fsWalk ( String userPath , Map < String , Object > attributes , String path ) { ArrayList < PathImpl > pathList = getMergePaths ( ) ; if ( ! userPath . startsWith ( "/" ) || pathList . size ( ) == 0 ) return new MergePath ( ( MergePath ) _root , userPath , attributes , path ) ; String bestPrefix = null ; for ( int i = 0 ; i < pathList . size ( ) ; i ++ ) { PathImpl subPath = pathList . get ( i ) ; String prefix = subPath . getPath ( ) ; if ( path . startsWith ( prefix ) && ( bestPrefix == null || bestPrefix . length ( ) < prefix . length ( ) ) ) { bestPrefix = prefix ; } } if ( bestPrefix != null ) { path = path . substring ( bestPrefix . length ( ) ) ; if ( ! path . startsWith ( "/" ) ) path = "/" + path ; return new MergePath ( ( MergePath ) _root , userPath , attributes , path ) ; } return pathList . get ( 0 ) . lookup ( userPath , attributes ) ; }
Walking down the path just extends the path . It won t be evaluated until opening .
256
18
139,330
public ArrayList < PathImpl > getResources ( String pathName ) { ArrayList < PathImpl > list = new ArrayList < PathImpl > ( ) ; String pathname = _pathname ; // XXX: why was this here? if ( pathname . startsWith ( "/" ) ) pathname = "." + pathname ; ArrayList < PathImpl > pathList = ( ( MergePath ) _root ) . _pathList ; for ( int i = 0 ; i < pathList . size ( ) ; i ++ ) { PathImpl path = pathList . get ( i ) ; path = path . lookup ( pathname ) ; ArrayList < PathImpl > subResources = path . getResources ( pathName ) ; for ( int j = 0 ; j < subResources . size ( ) ; j ++ ) { PathImpl newPath = subResources . get ( j ) ; if ( ! list . contains ( newPath ) ) list . add ( newPath ) ; } } return list ; }
Returns all the resources matching the path .
210
8
139,331
public String [ ] list ( ) throws IOException { ArrayList < String > list = new ArrayList < String > ( ) ; String pathname = _pathname ; // XXX:?? if ( pathname . startsWith ( "/" ) ) pathname = "." + pathname ; ArrayList < PathImpl > pathList = ( ( MergePath ) _root ) . _pathList ; for ( int i = 0 ; i < pathList . size ( ) ; i ++ ) { PathImpl path = pathList . get ( i ) ; path = path . lookup ( pathname ) ; if ( path . isDirectory ( ) ) { String [ ] subList = path . list ( ) ; for ( int j = 0 ; subList != null && j < subList . length ; j ++ ) { if ( ! list . contains ( subList [ j ] ) ) list . add ( subList [ j ] ) ; } } } return ( String [ ] ) list . toArray ( new String [ list . size ( ) ] ) ; }
List the merged directories .
220
5
139,332
@ Override public PersistentDependency createDepend ( ) { ArrayList < PathImpl > pathList = ( ( MergePath ) _root ) . _pathList ; if ( pathList . size ( ) == 1 ) return ( PersistentDependency ) pathList . get ( 0 ) . createDepend ( ) ; DependencyList dependList = new DependencyList ( ) ; for ( int i = 0 ; i < pathList . size ( ) ; i ++ ) { PathImpl path = pathList . get ( i ) ; PathImpl realPath = path . lookup ( _pathname ) ; dependList . add ( ( PersistentDependency ) realPath . createDepend ( ) ) ; } return dependList ; }
Creates a dependency .
157
5
139,333
public JType getGenericType ( ) { SignatureAttribute sigAttr = ( SignatureAttribute ) getAttribute ( "Signature" ) ; if ( sigAttr != null ) { return getClassLoader ( ) . parseParameterizedType ( sigAttr . getSignature ( ) ) ; } return getType ( ) ; }
Gets the typename .
68
6
139,334
public JAnnotation [ ] getDeclaredAnnotations ( ) { if ( _annotations == null ) { Attribute attr = getAttribute ( "RuntimeVisibleAnnotations" ) ; if ( attr instanceof OpaqueAttribute ) { byte [ ] buffer = ( ( OpaqueAttribute ) attr ) . getValue ( ) ; try { ByteArrayInputStream is = new ByteArrayInputStream ( buffer ) ; ConstantPool cp = _jClass . getConstantPool ( ) ; _annotations = JavaAnnotation . parseAnnotations ( is , cp , getClassLoader ( ) ) ; } catch ( IOException e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } } if ( _annotations == null ) { _annotations = new JavaAnnotation [ 0 ] ; } } return _annotations ; }
Returns the declared annotations .
184
5
139,335
public JavaField export ( JavaClass cl , JavaClass target ) { JavaField field = new JavaField ( ) ; field . setName ( _name ) ; field . setDescriptor ( _descriptor ) ; field . setAccessFlags ( _accessFlags ) ; target . getConstantPool ( ) . addUTF8 ( _name ) ; target . getConstantPool ( ) . addUTF8 ( _descriptor ) ; for ( int i = 0 ; i < _attributes . size ( ) ; i ++ ) { Attribute attr = _attributes . get ( i ) ; field . addAttribute ( attr . export ( cl , target ) ) ; } return field ; }
exports the field
149
4
139,336
@ Override public void write ( Buffer buffer , boolean isEnd ) throws IOException { if ( _s == null ) { buffer . free ( ) ; return ; } try { _needsFlush = true ; if ( buffer . isDirect ( ) ) { _totalWriteBytes += buffer . length ( ) ; _s . write ( buffer . direct ( ) ) ; return ; } _totalWriteBytes += buffer . length ( ) ; while ( buffer . length ( ) > 0 ) { _writeBuffer . clear ( ) ; buffer . read ( _writeBuffer ) ; _writeBuffer . flip ( ) ; _s . write ( _writeBuffer ) ; } } catch ( IOException e ) { IOException exn = ClientDisconnectException . create ( this + ":" + e , e ) ; try { close ( ) ; } catch ( IOException e1 ) { } throw exn ; } finally { buffer . free ( ) ; } }
Writes an nio buffer to the socket .
199
10
139,337
private boolean accept ( SocketBar socket ) { PortTcp port = port ( ) ; try { while ( ! port ( ) . isClosed ( ) ) { // Thread.interrupted(); if ( _serverSocket . accept ( socket ) ) { if ( port . isClosed ( ) ) { socket . close ( ) ; return false ; } else if ( isThrottle ( ) ) { socket . close ( ) ; } else { return true ; } } } } catch ( Throwable e ) { if ( port . isActive ( ) && log . isLoggable ( Level . FINER ) ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } } return false ; }
Accepts a new connection .
154
6
139,338
private int writeShort ( String value , int offset , int end ) throws IOException { int ch ; OutputStreamWithBuffer os = _os ; byte [ ] buffer = os . buffer ( ) ; int bOffset = os . offset ( ) ; end = Math . min ( end , offset + buffer . length - bOffset ) ; for ( ; offset < end && ( ch = value . charAt ( offset ) ) < 0x80 ; offset ++ ) { buffer [ bOffset ++ ] = ( byte ) ch ; } os . offset ( bOffset ) ; return offset ; }
Writes a short string .
121
6
139,339
public boolean write ( byte [ ] buf1 , int off1 , int len1 , byte [ ] buf2 , int off2 , int len2 , boolean isEnd ) throws IOException { if ( len1 == 0 ) { write ( buf2 , off2 , len2 , isEnd ) ; return true ; } else return false ; }
Writes a pair of buffer to the underlying stream .
72
11
139,340
public String removeAgreement ( String agreementId ) { Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/agreements/" + agreementId ) . request ( ) . header ( "Accept" , MediaType . APPLICATION_JSON ) . header ( "Content-Type" , MediaType . APPLICATION_JSON ) . buildDelete ( ) ; //SLA Core returns a text message if the response was succesfully not the object, this is not the best behaviour return invocation . invoke ( ) . readEntity ( String . class ) ; }
Creates proxied HTTP DELETE request to SeaClouds SLA core which removes the SLA from the SLA Core
121
26
139,341
public String notifyRulesReady ( Agreement slaAgreement ) { Entity content = Entity . entity ( "" , MediaType . TEXT_PLAIN ) ; Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/seaclouds/commands/rulesready?agreementId=" + slaAgreement . getAgreementId ( ) ) . request ( ) . header ( "Accept" , MediaType . APPLICATION_JSON ) . header ( "Content-Type" , MediaType . APPLICATION_JSON ) . buildPost ( content ) ; //SLA Core returns a text message if the response was succesfully not the object, this is not the best behaviour return invocation . invoke ( ) . readEntity ( String . class ) ; }
Creates proxied HTTP POST request to SeaClouds SLA core which notifies that the Monitoring Rules were installed in Tower4Clouds .
163
29
139,342
public Agreement getAgreement ( String agreementId ) { return getJerseyClient ( ) . target ( getEndpoint ( ) + "/agreements/" + agreementId ) . request ( ) . header ( "Accept" , MediaType . APPLICATION_JSON ) . header ( "Content-Type" , MediaType . APPLICATION_JSON ) . buildGet ( ) . invoke ( ) . readEntity ( Agreement . class ) ; }
Creates proxied HTTP GET request to SeaClouds SLA core which retrieves the Agreement details
90
20
139,343
public Agreement getAgreementByTemplateId ( String slaAgreementTemplateId ) { return getJerseyClient ( ) . target ( getEndpoint ( ) + "/seaclouds/commands/fromtemplate?templateId=" + slaAgreementTemplateId ) . request ( ) . header ( "Accept" , MediaType . APPLICATION_JSON ) . header ( "Content-Type" , MediaType . APPLICATION_JSON ) . buildGet ( ) . invoke ( ) . readEntity ( Agreement . class ) ; }
Creates proxied HTTP GET request to SeaClouds SLA which returns the Agreement according to the template id
112
22
139,344
public GuaranteeTermsStatus getAgreementStatus ( String agreementId ) { return getJerseyClient ( ) . target ( getEndpoint ( ) + "/agreements/" + agreementId + "/guaranteestatus" ) . request ( ) . header ( "Accept" , MediaType . APPLICATION_JSON ) . header ( "Content-Type" , MediaType . APPLICATION_JSON ) . buildGet ( ) . invoke ( ) . readEntity ( GuaranteeTermsStatus . class ) ; }
Creates proxied HTTP GET request to SeaClouds SLA core which retrieves the Agreement Status
107
20
139,345
public List < Violation > getGuaranteeTermViolations ( Agreement agreement , GuaranteeTerm guaranteeTerm ) { String json = getJerseyClient ( ) . target ( getEndpoint ( ) + "/violations?agreementId=" + agreement . getAgreementId ( ) + "&guaranteeTerm=" + guaranteeTerm . getName ( ) ) . request ( ) . header ( "Accept" , MediaType . APPLICATION_JSON ) . header ( "Content-Type" , MediaType . APPLICATION_JSON ) . buildGet ( ) . invoke ( ) . readEntity ( String . class ) ; try { return mapper . readValue ( json , new TypeReference < List < Violation > > ( ) { } ) ; } catch ( IOException e ) { /* * TODO: Change Runtime for a DashboardException */ throw new RuntimeException ( e ) ; } }
Creates proxied HTTP GET request to SeaClouds SLA core which retrieves the Agreement Term Violations
188
22
139,346
@ Override public T readObject ( InRawH3 is , InH3Amp in ) { T bean = newInstance ( ) ; in . ref ( bean ) ; FieldSerBase [ ] fields = _fields ; int size = fields . length ; for ( int i = 0 ; i < size ; i ++ ) { fields [ i ] . read ( bean , is , in ) ; } return bean ; }
Reads the bean from the stream .
88
8
139,347
public InvocationRouter < InvocationBaratine > buildRouter ( WebApp webApp ) { // find views InjectorAmp inject = webApp . inject ( ) ; buildViews ( inject ) ; ArrayList < RouteMap > mapList = new ArrayList <> ( ) ; ServicesAmp manager = webApp . services ( ) ; ServiceRefAmp serviceRef = manager . newService ( new RouteService ( ) ) . ref ( ) ; while ( _routes . size ( ) > 0 ) { ArrayList < RouteWebApp > routes = new ArrayList <> ( _routes ) ; _routes . clear ( ) ; for ( RouteWebApp route : routes ) { mapList . addAll ( route . toMap ( inject , serviceRef ) ) ; } } /* for (RouteConfig config : _routeList) { RouteBaratine route = config.buildRoute(); mapList.add(new RouteMap("", route)); } */ RouteMap [ ] routeArray = new RouteMap [ mapList . size ( ) ] ; mapList . toArray ( routeArray ) ; return new InvocationRouterWebApp ( webApp , routeArray ) ; }
Builds the web - app s router
255
8
139,348
public void splitQueryAndUnescape ( I invocation , byte [ ] rawURIBytes , int uriLength ) throws IOException { for ( int i = 0 ; i < uriLength ; i ++ ) { if ( rawURIBytes [ i ] == ' ' ) { i ++ ; // XXX: should be the host encoding? String queryString = byteToChar ( rawURIBytes , i , uriLength - i , "ISO-8859-1" ) ; invocation . setQueryString ( queryString ) ; uriLength = i - 1 ; break ; } } String rawURIString = byteToChar ( rawURIBytes , 0 , uriLength , "ISO-8859-1" ) ; invocation . setRawURI ( rawURIString ) ; String decodedURI = normalizeUriEscape ( rawURIBytes , 0 , uriLength , _encoding ) ; decodedURI = decodeURI ( rawURIString , decodedURI , invocation ) ; String uri = normalizeUri ( decodedURI ) ; invocation . setURI ( uri ) ; }
Splits out the query string and unescape the value .
231
12
139,349
public void splitQuery ( I invocation , String rawURI ) throws IOException { int p = rawURI . indexOf ( ' ' ) ; if ( p > 0 ) { invocation . setQueryString ( rawURI . substring ( p + 1 ) ) ; rawURI = rawURI . substring ( 0 , p ) ; } invocation . setRawURI ( rawURI ) ; String uri = normalizeUri ( rawURI ) ; invocation . setURI ( uri ) ; }
Splits out the query string and normalizes the URI assuming nothing needs unescaping .
102
18
139,350
public void normalizeURI ( I invocation , String rawURI ) throws IOException { invocation . setRawURI ( rawURI ) ; String uri = normalizeUri ( rawURI ) ; invocation . setURI ( uri ) ; }
Just normalize the URI .
50
6
139,351
private static String normalizeUriEscape ( byte [ ] rawUri , int i , int len , String encoding ) throws IOException { ByteToChar converter = allocateConverter ( ) ; // XXX: make this configurable if ( encoding == null ) { encoding = "utf-8" ; } try { converter . setEncoding ( encoding ) ; } catch ( UnsupportedEncodingException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; } try { while ( i < len ) { int ch = rawUri [ i ++ ] & 0xff ; if ( ch == ' ' ) i = scanUriEscape ( converter , rawUri , i , len ) ; else converter . addByte ( ch ) ; } String result = converter . getConvertedString ( ) ; freeConverter ( converter ) ; return result ; } catch ( Exception e ) { throw new BadRequestException ( L . l ( "The URL contains escaped bytes unsupported by the {0} encoding." , encoding ) ) ; } }
Converts the escaped URI to a string .
227
9
139,352
private static int scanUriEscape ( ByteToChar converter , byte [ ] rawUri , int i , int len ) throws IOException { int ch1 = i < len ? ( rawUri [ i ++ ] & 0xff ) : - 1 ; if ( ch1 == ' ' ) { ch1 = i < len ? ( rawUri [ i ++ ] & 0xff ) : - 1 ; int ch2 = i < len ? ( rawUri [ i ++ ] & 0xff ) : - 1 ; int ch3 = i < len ? ( rawUri [ i ++ ] & 0xff ) : - 1 ; int ch4 = i < len ? ( rawUri [ i ++ ] & 0xff ) : - 1 ; converter . addChar ( ( char ) ( ( toHex ( ch1 ) << 12 ) + ( toHex ( ch2 ) << 8 ) + ( toHex ( ch3 ) << 4 ) + ( toHex ( ch4 ) ) ) ) ; } else { int ch2 = i < len ? ( rawUri [ i ++ ] & 0xff ) : - 1 ; int b = ( toHex ( ch1 ) << 4 ) + toHex ( ch2 ) ; ; converter . addByte ( b ) ; } return i ; }
Scans the next character from URI adding it to the converter .
280
13
139,353
private static int toHex ( int ch ) { if ( ch >= ' ' && ch <= ' ' ) return ch - ' ' ; else if ( ch >= ' ' && ch <= ' ' ) return ch - ' ' + 10 ; else if ( ch >= ' ' && ch <= ' ' ) return ch - ' ' + 10 ; else return - 1 ; }
Convert a character to hex
77
6
139,354
public static PathImpl getLocalWorkDir ( ClassLoader loader ) { PathImpl path = _localWorkDir . get ( loader ) ; if ( path != null ) return path ; path = getTmpWorkDir ( ) ; _localWorkDir . setGlobal ( path ) ; try { path . mkdirs ( ) ; } catch ( java . io . IOException e ) { } return path ; }
Returns the local work directory .
85
6
139,355
public static void setLocalWorkDir ( PathImpl path , ClassLoader loader ) { try { if ( path instanceof MergePath ) path = ( ( MergePath ) path ) . getWritePath ( ) ; if ( path instanceof MemoryPath ) { String pathName = path . getPath ( ) ; path = WorkDir . getTmpWorkDir ( ) . lookup ( "qa/" + pathName ) ; } // path.mkdirs(); } catch ( Exception e ) { throw new RuntimeException ( e ) ; } _localWorkDir . set ( path , loader ) ; }
Sets the work dir .
123
6
139,356
@ Override public < S , T > Convert < S , T > converter ( Class < S > source , Class < T > target ) { ConvertFrom < S > convertType = getOrCreate ( source ) ; return convertType . converter ( target ) ; }
Returns the converter for a given source type and target type .
55
12
139,357
private < S > ConvertManagerTypeImpl < S > getOrCreate ( Class < S > sourceType ) { ConvertManagerTypeImpl < S > convertType = ( ConvertManagerTypeImpl < S > ) _convertMap . get ( sourceType ) ; if ( convertType != null ) { return convertType ; } convertType = new ConvertManagerTypeImpl <> ( sourceType ) ; _convertMap . putIfAbsent ( sourceType , convertType ) ; return ( ConvertManagerTypeImpl < S > ) _convertMap . get ( sourceType ) ; }
Returns the ConvertManagerTypeImpl for a given source type .
120
12
139,358
protected int nextOffset ( ) { int opcode = getCode ( ) [ _offset ] & 0xff ; int length = OP_LEN [ opcode ] ; switch ( opcode ) { case GOTO : case GOTO_W : case RET : case IRETURN : case LRETURN : case FRETURN : case DRETURN : case ARETURN : case RETURN : case ATHROW : return - 1 ; case TABLESWITCH : { int arg = _offset + 1 ; arg += ( 4 - arg % 4 ) % 4 ; int low = getInt ( arg + 4 ) ; int high = getInt ( arg + 8 ) ; return arg + 12 + ( high - low + 1 ) * 4 ; } case LOOKUPSWITCH : { return - 1 ; /* int arg = _offset + 1; arg += (4 - arg % 4) % 4; int n = getInt(arg + 4); int next = arg + 12 + n * 8; return next; */ } case WIDE : { int op2 = getCode ( ) [ _offset + 1 ] & 0xff ; if ( op2 == IINC ) length = 5 ; else length = 3 ; break ; } } if ( length < 0 || length > 0x10 ) throw new UnsupportedOperationException ( L . l ( "{0}: can't handle opcode {1}" , "" + _offset , "" + getOpcode ( ) ) ) ; return _offset + length + 1 ; }
Goes to the next opcode .
321
8
139,359
public boolean isBranch ( ) { switch ( getOpcode ( ) ) { case IFNULL : case IFNONNULL : case IFNE : case IFEQ : case IFLT : case IFGE : case IFGT : case IFLE : case IF_ICMPEQ : case IF_ICMPNE : case IF_ICMPLT : case IF_ICMPGE : case IF_ICMPGT : case IF_ICMPLE : case IF_ACMPEQ : case IF_ACMPNE : case JSR : case JSR_W : case GOTO : case GOTO_W : return true ; } return false ; }
Returns true for a simple branch i . e . a branch with a simple target .
142
17
139,360
public ConstantPoolEntry getConstantArg ( ) { switch ( getOpcode ( ) ) { case LDC : return _javaClass . getConstantPool ( ) . getEntry ( getByteArg ( ) ) ; case LDC_W : return _javaClass . getConstantPool ( ) . getEntry ( getShortArg ( ) ) ; default : throw new UnsupportedOperationException ( ) ; } }
Returns a constant pool item .
87
6
139,361
public int getShort ( int offset ) { int b0 = getCode ( ) [ offset + 0 ] & 0xff ; int b1 = getCode ( ) [ offset + 1 ] & 0xff ; return ( short ) ( ( b0 << 8 ) + b1 ) ; }
Reads a short value .
60
6
139,362
public int getInt ( int offset ) { byte [ ] code = getCode ( ) ; int b0 = code [ offset + 0 ] & 0xff ; int b1 = code [ offset + 1 ] & 0xff ; int b2 = code [ offset + 2 ] & 0xff ; int b3 = code [ offset + 3 ] & 0xff ; return ( b0 << 24 ) + ( b1 << 16 ) + ( b2 << 8 ) + b3 ; }
Reads an int argument .
101
6
139,363
private void analyze ( Analyzer analyzer , boolean allowFlow , IntArray pendingTargets , IntArray completedTargets ) throws Exception { pending : while ( pendingTargets . size ( ) > 0 ) { int pc = pendingTargets . pop ( ) ; if ( allowFlow ) { if ( completedTargets . contains ( pc ) ) continue pending ; completedTargets . add ( pc ) ; } setOffset ( pc ) ; flow : do { pc = getOffset ( ) ; if ( pc < 0 ) throw new IllegalStateException ( ) ; if ( ! allowFlow ) { if ( completedTargets . contains ( pc ) ) break flow ; completedTargets . add ( pc ) ; } if ( isBranch ( ) ) { int targetPC = getBranchTarget ( ) ; if ( ! pendingTargets . contains ( targetPC ) ) pendingTargets . add ( targetPC ) ; } else if ( isSwitch ( ) ) { int [ ] switchTargets = getSwitchTargets ( ) ; for ( int i = 0 ; i < switchTargets . length ; i ++ ) { if ( ! pendingTargets . contains ( switchTargets [ i ] ) ) pendingTargets . add ( switchTargets [ i ] ) ; } } analyzer . analyze ( this ) ; } while ( next ( ) ) ; } }
Analyzes the code for a basic block .
300
9
139,364
public static ServerBartender currentSelfServer ( ) { NetworkSystem clusterService = current ( ) ; if ( clusterService == null ) throw new IllegalStateException ( L . l ( "{0} is not available in this context" , NetworkSystem . class . getSimpleName ( ) ) ) ; return clusterService . selfServer ( ) ; }
Returns the current network service .
72
6
139,365
public ConnectionTcp findConnectionByThreadId ( long threadId ) { for ( PortTcp listener : getPorts ( ) ) { ConnectionTcp conn = listener . findConnectionByThreadId ( threadId ) ; if ( conn != null ) return conn ; } return null ; }
Finds the TcpConnection given the threadId
60
10
139,366
private void updateClusterRoot ( ) { ArrayList < ServerHeartbeat > serverList = new ArrayList <> ( ) ; for ( ServerHeartbeat server : _serverSelf . getCluster ( ) . getServers ( ) ) { serverList . add ( server ) ; } Collections . sort ( serverList , ( x , y ) -> compareClusterRoot ( x , y ) ) ; UpdatePodBuilder builder = new UpdatePodBuilder ( ) ; builder . name ( "cluster_root" ) ; builder . cluster ( _serverSelf . getCluster ( ) ) ; builder . type ( PodType . solo ) ; builder . depth ( 16 ) ; for ( ServerHeartbeat server : serverList ) { builder . server ( server . getAddress ( ) , server . port ( ) ) ; } long sequence = CurrentTime . currentTime ( ) ; sequence = Math . max ( sequence , _clusterRoot . getSequence ( ) + 1 ) ; builder . sequence ( sequence ) ; UpdatePod update = builder . build ( ) ; updatePodProxy ( update ) ; }
Compare and merge the cluster_root with an update .
228
11
139,367
void onJoinStart ( ) { //long now = CurrentTime.getCurrentTime(); ArrayList < UpdatePod > updatePods = new ArrayList <> ( ) ; updateClusterRoot ( ) ; /* for (UpdatePod updatePod : _podUpdateMap.values()) { if (updatePod.getSequence() == 0) { updatePods.add(new UpdatePod(updatePod, now)); } } */ /* for (UpdatePod updatePod : updatePods) { updatePod(updatePod); } */ updatePods . addAll ( _podUpdateMap . values ( ) ) ; for ( UpdatePod updatePod : updatePods ) { updatePod ( updatePod ) ; } // XXX: }
Update the sequence for all init pods after the join has completed .
152
13
139,368
private int keyColumnStart ( ) { int offset = 0 ; for ( int i = 0 ; i < _columns . length ; i ++ ) { if ( offset == _keyStart ) { return i ; } offset += _columns [ i ] . length ( ) ; } throw new IllegalStateException ( ) ; }
First key column index .
68
5
139,369
private int keyColumnEnd ( ) { int offset = 0 ; for ( int i = 0 ; i < _columns . length ; i ++ ) { if ( offset == _keyStart + _keyLength ) { return i ; } offset += _columns [ i ] . length ( ) ; } if ( offset == _keyStart + _keyLength ) { return _columns . length ; } throw new IllegalStateException ( ) ; }
End key column index the index after the final key .
93
11
139,370
public void autoFill ( RowCursor cursor ) { for ( Column col : columns ( ) ) { col . autoFill ( cursor . buffer ( ) , 0 ) ; } }
autofill generated values
37
5
139,371
void readStream ( InputStream is , byte [ ] buffer , int offset , RowCursor cursor ) throws IOException { for ( Column column : columns ( ) ) { column . readStream ( is , buffer , offset , cursor ) ; } for ( Column column : blobs ( ) ) { column . readStreamBlob ( is , buffer , offset , cursor ) ; } }
Fills a cursor given an input stream
79
8
139,372
int readCheckpoint ( ReadStream is , byte [ ] blockBuffer , int rowOffset , int blobTail ) throws IOException { int rowLength = length ( ) ; if ( rowOffset < blobTail ) { return - 1 ; } for ( Column column : columns ( ) ) { blobTail = column . readCheckpoint ( is , blockBuffer , rowOffset , rowLength , blobTail ) ; } return blobTail ; }
Reads column - specific data like blobs from the checkpoint .
94
13
139,373
public void validate ( byte [ ] buffer , int rowOffset , int rowHead , int blobTail ) { for ( Column column : columns ( ) ) { column . validate ( buffer , rowOffset , rowHead , blobTail ) ; } }
Validates the row checking for corruption .
52
8
139,374
static void incrementKey ( byte [ ] key ) { for ( int i = key . length - 1 ; i >= 0 ; i -- ) { int v = key [ i ] & 0xff ; if ( v < 0xff ) { key [ i ] = ( byte ) ( v + 1 ) ; return ; } key [ i ] = 0 ; } }
Increment a key .
75
5
139,375
static void decrementKey ( byte [ ] key ) { for ( int i = key . length - 1 ; i >= 0 ; i -- ) { int v = key [ i ] & 0xff ; if ( v > 0 ) { key [ i ] = ( byte ) ( v - 1 ) ; return ; } key [ i ] = ( byte ) 0xff ; } }
Decrement a key .
79
5
139,376
public void setThreadMax ( int max ) { if ( max == _threadMax ) { // avoid update() overhead if unchanged return ; } if ( max <= 0 ) { max = DEFAULT_THREAD_MAX ; } if ( max < _idleMin ) throw new ConfigException ( L . l ( "IdleMin ({0}) must be less than ThreadMax ({1})" , _idleMin , max ) ) ; if ( max < 1 ) throw new ConfigException ( L . l ( "ThreadMax ({0}) must be greater than zero" , max ) ) ; _threadMax = max ; update ( ) ; }
Sets the maximum number of threads .
135
8
139,377
public void setIdleMax ( int max ) { if ( max == _idleMax ) { // avoid update() overhead if unchanged return ; } if ( max <= 0 ) { max = DEFAULT_IDLE_MAX ; } if ( _threadMax < max ) throw new ConfigException ( L . l ( "IdleMax ({0}) must be less than ThreadMax ({1})" , max , _threadMax ) ) ; if ( max <= 0 ) throw new ConfigException ( L . l ( "IdleMax ({0}) must be greater than 0." , max ) ) ; _idleMax = max ; update ( ) ; }
Sets the maximum number of idle threads .
137
9
139,378
public boolean isIdleExpire ( ) { if ( ! _lifecycle . isActive ( ) ) return true ; long now = currentTimeActual ( ) ; long idleExpire = _threadIdleExpireTime . get ( ) ; int idleCount = _idleCount . get ( ) ; // if idle queue is full and the expire is set, return and exit if ( _idleMin < idleCount ) { long nextIdleExpire = now + _idleTimeout ; if ( _idleMax < idleCount && _idleMin < _idleMax ) { /* && _threadIdleExpireTime.compareAndSet(idleExpire, nextIdleExpire)) { */ _threadIdleExpireTime . compareAndSet ( idleExpire , nextIdleExpire ) ; return true ; } else if ( idleExpire < now && _threadIdleExpireTime . compareAndSet ( idleExpire , nextIdleExpire ) ) { return true ; } } return false ; }
Returns true if the thread should expire instead of going to the idle state .
223
15
139,379
public static ReadStreamOld open ( String string ) { VfsStringReader ss = new VfsStringReader ( string ) ; ReadStreamOld rs = new ReadStreamOld ( ss ) ; try { rs . setEncoding ( "UTF-8" ) ; } catch ( Exception e ) { } //rs.setPath(new NullPath("string")); return rs ; }
Creates a new ReadStream reading bytes from the given string .
79
13
139,380
public static void clearFreeLists ( ) { while ( _freeStandard . allocate ( ) != null ) { } while ( _freeSmall . allocate ( ) != null ) { } while ( _freeLarge . allocate ( ) != null ) { } }
Free data for OOM .
53
6
139,381
@ Override @ InService ( PageServiceImpl . class ) void writeImpl ( TableKelp table , PageServiceImpl pageServiceImpl , TableWriterService readWrite , SegmentStream sOut , long oldSequence , int saveLength , int saveTail ) { Objects . requireNonNull ( sOut ) ; // System.out.println("WIMPL:" + this + " "+ Long.toHexString(System.identityHashCode(this)) + " " + _stub); if ( saveLength <= 0 || oldSequence != sOut . getSequence ( ) || _stub == null || ! _stub . allowDelta ( ) ) { PageLeafImpl newPage ; if ( ! isDirty ( ) && ( _blocks . length == 0 || _blocks [ 0 ] . isCompact ( ) ) ) { newPage = copy ( getSequence ( ) ) ; } else { newPage = compact ( table ) ; } int sequenceWrite = newPage . nextWriteSequence ( ) ; if ( ! pageServiceImpl . compareAndSetLeaf ( this , newPage ) && ! pageServiceImpl . compareAndSetLeaf ( _stub , newPage ) ) { System . out . println ( "HMPH: " + pageServiceImpl . getPage ( getId ( ) ) + " " + this + " " + _stub ) ; } saveLength = newPage . getDataLengthWritten ( ) ; // newPage.write(db, pageActor, sOut, saveLength); // oldSequence = newPage.getSequence(); saveTail = newPage . getSaveTail ( ) ; newPage . clearDirty ( ) ; readWrite . writePage ( newPage , sOut , oldSequence , saveLength , saveTail , sequenceWrite , Result . of ( x -> newPage . afterDataFlush ( pageServiceImpl , sequenceWrite ) ) ) ; } else { int sequenceWrite = nextWriteSequence ( ) ; clearDirty ( ) ; readWrite . writePage ( this , sOut , oldSequence , saveLength , saveTail , sequenceWrite , Result . of ( x -> afterDataFlush ( pageServiceImpl , sequenceWrite ) ) ) ; } }
Sends a write - request to the sequence writer for the page .
482
14
139,382
@ Override @ InService ( TableWriterService . class ) public Page writeCheckpoint ( TableKelp table , OutSegment sOut , long oldSequence , int saveLength , int saveTail , int saveSequence ) throws IOException { BlockLeaf [ ] blocks = _blocks ; int size = BLOCK_SIZE * blocks . length ; WriteStream os = sOut . out ( ) ; int available = sOut . getAvailable ( ) ; if ( available < os . position ( ) + size ) { return null ; } long newSequence = sOut . getSequence ( ) ; if ( newSequence < oldSequence ) { return null ; } compareAndSetSequence ( oldSequence , newSequence ) ; PageLeafStub stub = _stub ; // System.out.println("WRC: " + this + " " + stub); Type type ; if ( saveLength > 0 && oldSequence == newSequence && stub != null && stub . allowDelta ( ) ) { int offset = ( int ) os . position ( ) ; type = writeDelta ( table , sOut . out ( ) , saveLength ) ; int length = ( int ) ( os . position ( ) - offset ) ; stub . addDelta ( table , offset , length ) ; } else { // _lastSequence = newSequence; int offset = ( int ) os . position ( ) ; if ( sOut . isCompress ( ) ) { try ( OutputStream zOut = sOut . outCompress ( ) ) { type = writeCheckpointFull ( table , zOut , saveTail ) ; } } else { type = writeCheckpointFull ( table , sOut . out ( ) , saveTail ) ; } int length = ( int ) ( os . position ( ) - offset ) ; // create stub to the newly written data, allowing this memory to be // garbage collected stub = new PageLeafStub ( getId ( ) , getNextId ( ) , sOut . getSegment ( ) , offset , length ) ; stub . setLeafRef ( this ) ; _stub = stub ; } _writeType = type ; return this ; }
Callback from the writer and gc to write the page .
468
12
139,383
private PageLeafImpl compact ( TableKelp table ) { long now = CurrentTime . currentTime ( ) / 1000 ; Set < PageLeafEntry > entries = fillEntries ( table ) ; ArrayList < BlockLeaf > blocks = new ArrayList <> ( ) ; BlockLeaf block = new BlockLeaf ( getId ( ) ) ; blocks . add ( block ) ; Row row = table . row ( ) ; for ( PageLeafEntry entry : entries ) { if ( entry . getCode ( ) != INSERT && entry . getExpires ( ) <= now ) { continue ; } while ( ! block . addEntry ( row , entry ) ) { block = new BlockLeaf ( getId ( ) ) ; blocks . add ( block ) ; } } PageLeafImpl newPage = new PageLeafImpl ( getId ( ) , getNextId ( ) , getSequence ( ) , _table , getMinKey ( ) , getMaxKey ( ) , blocks ) ; newPage . validate ( table ) ; newPage . toSorted ( table ) ; if ( isDirty ( ) ) { newPage . setDirty ( ) ; } if ( _stub != null ) { _stub . copyToCompact ( newPage ) ; } return newPage ; }
Compacts the leaf by rebuilding the delta entries and discarding obsolete removed entries .
278
16
139,384
@ InService ( SegmentServiceImpl . class ) private Type writeCheckpointFull ( TableKelp table , OutputStream os , int saveTail ) throws IOException { os . write ( getMinKey ( ) ) ; os . write ( getMaxKey ( ) ) ; /* db/2310 if (Arrays.equals(getMinKey(), getMaxKey())) { throw new IllegalStateException("bad keys"); } */ BlockLeaf [ ] blocks = _blocks ; int index = blocks . length - ( saveTail / BLOCK_SIZE ) ; int rowFirst = saveTail % BLOCK_SIZE ; BitsUtil . writeInt16 ( os , blocks . length - index ) ; if ( blocks . length <= index ) { return Type . LEAF ; } blocks [ index ] . writeCheckpointFull ( os , rowFirst ) ; for ( int i = index + 1 ; i < blocks . length ; i ++ ) { blocks [ i ] . writeCheckpointFull ( os , 0 ) ; } return Type . LEAF ; }
Writes the page to the output stream as a full checkpoint .
225
13
139,385
@ InService ( PageServiceImpl . class ) static PageLeafImpl readCheckpointFull ( TableKelp table , PageServiceImpl pageActor , InputStream is , int pid , int nextPid , long sequence ) throws IOException { byte [ ] minKey = new byte [ table . getKeyLength ( ) ] ; byte [ ] maxKey = new byte [ table . getKeyLength ( ) ] ; int count = 0 ; BlockLeaf [ ] blocks ; IoUtil . readAll ( is , minKey , 0 , minKey . length ) ; IoUtil . readAll ( is , maxKey , 0 , maxKey . length ) ; count = BitsUtil . readInt16 ( is ) ; blocks = new BlockLeaf [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { blocks [ i ] = new BlockLeaf ( pid ) ; blocks [ i ] . readCheckpointFull ( is ) ; } if ( count == 0 ) { blocks = new BlockLeaf [ ] { new BlockLeaf ( pid ) } ; } PageLeafImpl page = new PageLeafImpl ( pid , nextPid , sequence , table , minKey , maxKey , blocks ) ; page . clearDirty ( ) ; page . validate ( table ) ; page . toSorted ( table ) ; return page ; }
Reads a full checkpoint entry into the page .
289
10
139,386
void readCheckpointDelta ( TableKelp table , PageServiceImpl pageActor , ReadStream is , int length ) throws IOException { Row row = table . row ( ) ; // int keyLength = row.getKeyLength(); int removeLength = row . removeLength ( ) ; int rowLength = row . length ( ) ; BlockLeaf block = _blocks [ 0 ] ; long endPosition = is . position ( ) + length ; int rowHead = block . rowHead ( ) ; int blobTail = block . getBlobTail ( ) ; long pos ; while ( ( pos = is . position ( ) ) < endPosition ) { int code = is . read ( ) ; is . unread ( ) ; code = code & CODE_MASK ; if ( code == REMOVE ) { rowHead -= removeLength ; if ( rowHead < blobTail ) { block = extendBlocks ( ) ; rowHead = BLOCK_SIZE - removeLength ; blobTail = 0 ; } is . readAll ( block . getBuffer ( ) , rowHead , removeLength ) ; } else if ( code == INSERT ) { rowHead -= rowLength ; while ( ( blobTail = row . readCheckpoint ( is , block . getBuffer ( ) , rowHead , blobTail ) ) < 0 ) { //is.setPosition(pos + 1); is . position ( pos ) ; block = extendBlocks ( ) ; rowHead = BLOCK_SIZE - rowLength ; blobTail = 0 ; } // byte []buffer = block.getBuffer(); // buffer[rowHead] = (byte) ((buffer[rowHead] & ~CODE_MASK) | INSERT); } else { throw new IllegalStateException ( L . l ( "{0} Corrupted checkpoint at pos={1} with code {2}" , this , pos , code ) ) ; } block . rowHead ( rowHead ) ; block . setBlobTail ( blobTail ) ; } clearDirty ( ) ; validate ( table ) ; }
Reads a delta entry from the checkpoint .
436
9
139,387
void validate ( TableKelp table ) { if ( ! table . isValidate ( ) ) { return ; } Row row = table . row ( ) ; for ( BlockLeaf block : _blocks ) { block . validateBlock ( row ) ; } }
Validates the leaf blocks
55
5
139,388
void addDelta ( TableKelp db , int offset , int length ) { if ( _delta == null ) { _delta = new int [ 2 * db . getDeltaMax ( ) ] ; } _delta [ _deltaTail ++ ] = offset ; _delta [ _deltaTail ++ ] = length ; }
Adds a delta record to the leaf stub .
74
9
139,389
public String [ ] fetchAndPlan ( String aam ) throws ParsingException , IOException { String offerings = this . fetchOfferings ( ) ; return this . plan ( aam , offerings ) ; }
Fetches offerings from the Discoverer and makes plans
44
12
139,390
public String [ ] plan ( String aam , String uniqueOfferingsTosca ) throws ParsingException , IOException { log . info ( "Planning for aam: \n" + aam ) ; //Get offerings log . info ( "Getting Offeing Step: Start" ) ; Map < String , Pair < NodeTemplate , String > > offerings = parseOfferings ( uniqueOfferingsTosca ) ; // getOfferingsFromDiscoverer(); log . info ( "Getting Offeing Step: Complete" ) ; log . info ( "\nNot deployable offering have been filtered!" ) ; log . info ( "\nDeployable offerings have location: " + deployableProviders ) ; log . info ( "Got " + offerings . size ( ) + " offerings from discoverer:" ) ; //Matchmake log . info ( "Matchmaking Step: Start" ) ; Matchmaker mm = new Matchmaker ( ) ; Map < String , HashSet < String > > matchingOfferings = mm . match ( ToscaSerializer . fromTOSCA ( aam ) , offerings ) ; log . info ( "Matchmaking Step: Complete" ) ; //Optimize String mmOutput = "" ; try { mmOutput = generateMMOutput2 ( matchingOfferings , offerings ) ; } catch ( JsonProcessingException e ) { log . error ( "Error preparing matchmaker output for optimization" , e ) ; } for ( String s : matchingOfferings . keySet ( ) ) { log . info ( "Module " + s + "has matching offerings: " + matchingOfferings . get ( s ) ) ; } log . info ( "Optimization Step: Start" ) ; log . info ( "Calling optimizer with suitable offerings: \n" + mmOutput ) ; Optimizer optimizer = new Optimizer ( ) ; String [ ] outputPlans = optimizer . optimize ( aam , mmOutput ) ; log . info ( "Optimzer result: " + Arrays . asList ( outputPlans ) ) ; log . info ( "Optimization Step: Complete" ) ; return outputPlans ; }
Makes plans starting from the AAM and a String containing the TOSCA of the offerings available to generate the plans
460
24
139,391
public String [ ] fetchAndRePlan ( String aam , List < String > modulesToFilter ) throws ParsingException , IOException { String offerings = this . fetchOfferings ( ) ; return this . rePlan ( aam , offerings , modulesToFilter ) ; }
Fetches offerings from the Discoverer and replan
58
12
139,392
private String fetchOfferings ( ) { DiscovererFetchallResult allOfferings = null ; try { String discovererOutput = discovererClient . getRequest ( "fetch_all" , Collections . EMPTY_LIST ) ; ObjectMapper mapper = new ObjectMapper ( ) ; allOfferings = mapper . readValue ( discovererOutput , DiscovererFetchallResult . class ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } String offerings = allOfferings . offering ; return offerings ; }
Fetches the list offerings from the Discoverer
126
11
139,393
ModuleMarshal marshal ( Class < ? > sourceType , Class < ? > targetType , Class < ? > declaredTargetType ) { ImportKey key = new ImportKey ( sourceType , targetType ) ; ModuleMarshal marshal = _marshalMap . get ( key ) ; if ( marshal != null ) { return marshal ; } marshal = marshalImpl ( sourceType , targetType , declaredTargetType ) ; _marshalMap . putIfAbsent ( key , marshal ) ; return marshal ; }
Returns the marshal to convert from the sourceType to the targetType .
114
15
139,394
public static int getBiggestPrime ( long value ) { for ( int i = PRIMES . length - 1 ; i >= 0 ; i -- ) { if ( PRIMES [ i ] <= value ) { return PRIMES [ i ] ; } } return 2 ; }
Returns the largest prime less than the given bits .
59
10
139,395
public void setCertificateChainFile ( Path certificateChainFile ) { try { _certificateChainFile = certificateChainFile . toRealPath ( ) . toString ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Sets the certificateChainFile .
55
7
139,396
public void setCACertificatePath ( Path caCertificatePath ) { try { _caCertificatePath = caCertificatePath . toRealPath ( ) . toString ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Sets the caCertificatePath .
58
8
139,397
public void setCACertificateFile ( Path caCertificateFile ) { try { _caCertificateFile = caCertificateFile . toRealPath ( ) . toString ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Sets the caCertificateFile .
58
8
139,398
public void setCARevocationPath ( Path caRevocationPath ) { try { _caRevocationPath = caRevocationPath . toRealPath ( ) . toString ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Sets the caRevocationPath .
57
8
139,399
public void setCARevocationFile ( Path caRevocationFile ) { try { _caRevocationFile = caRevocationFile . toRealPath ( ) . toString ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Sets the caRevocationFile .
57
8