idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
139,800
public static StderrStream create ( ) { if ( _stderr == null ) { _stderr = new StderrStream ( ) ; ConstPath path = new ConstPath ( null , _stderr ) ; path . setScheme ( "stderr" ) ; //_stderr.setPath(path); } return _stderr ; }
Returns the StderrStream singleton
81
8
139,801
public static long generate ( long hash , final CharSequence value ) { final long m = 0xc6a4a7935bd1e995 L ; final int r = 47 ; int strlen = value . length ( ) ; int length = 2 * strlen ; hash ^= length * m ; int len4 = strlen / 4 ; int offset = 0 ; for ( int i = 0 ; i < len4 ; i ++ ) { final int index = i * 4 + offset ; long k = ( value . charAt ( index + 0 ) | ( ( long ) value . charAt ( index + 1 ) << 16 ) | ( ( long ) value . charAt ( index + 2 ) << 32 ) | ( ( long ) value . charAt ( index + 3 ) << 48 ) ) ; k *= m ; k ^= k >>> r ; k *= m ; hash ^= k ; hash *= m ; } final int off = offset + ( strlen & ~ 0x3 ) ; switch ( strlen % 4 ) { case 3 : hash ^= ( long ) value . charAt ( off + 2 ) << 48 ; case 2 : hash ^= ( long ) value . charAt ( off + 1 ) << 32 ; case 1 : hash ^= ( long ) value . charAt ( off + 0 ) << 16 ; hash *= m ; } hash ^= hash >>> r ; hash *= m ; hash ^= hash >>> r ; return hash ; }
Calculates hash from a String using utf - 16 encoding
314
13
139,802
public static byte [ ] process ( CharSequence html ) { ByteArrayOutputStream baos = null ; try { baos = new ByteArrayOutputStream ( ) ; process ( html , baos ) ; return baos . toByteArray ( ) ; } finally { if ( baos != null ) { try { baos . close ( ) ; } catch ( IOException e ) { log . warn ( "Close Byte Array Inpout Stream Error Caused." , e ) ; } } } }
process html to xls
105
5
139,803
public static void process ( CharSequence html , OutputStream output ) { new TableToXls ( ) . doProcess ( html instanceof String ? ( String ) html : html . toString ( ) , output ) ; }
process html to output stream
47
5
139,804
@ Override public void writeSend ( StubAmp actor , String methodName , Object [ ] args , InboxAmp inbox ) { try ( OutputStream os = openItem ( inbox ) ) { // XXX: should keep open try ( OutH3 out = _serializer . out ( os ) ) { String key = actor . journalKey ( ) ; out . writeLong ( CODE_SEND ) ; out . writeString ( key ) ; out . writeString ( methodName ) ; out . writeLong ( args . length ) ; for ( Object arg : args ) { out . writeObject ( arg ) ; } } //_count++; } catch ( IOException e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } }
Writes the send to the journal . The queryRef values are not saved because restoring them does not make sense .
164
23
139,805
protected boolean addDependencies ( DependencyContainer container ) { /* XXX: if (_classPath instanceof JarPath) { container.add(_depend); return false; } else */ if ( _hasJNIReload ) { container . add ( this ) ; return true ; } else if ( _sourcePath == null ) { container . add ( _depend ) ; return false ; } else { container . add ( this ) ; return true ; } }
Adds the dependencies returning true if it s adding itself .
96
11
139,806
public boolean reloadIsModified ( ) { if ( _classIsModified ) { return true ; } if ( ! _hasJNIReload || ! _classPath . canRead ( ) ) { return true ; } try { long length = _classPath . length ( ) ; Class < ? > cl = _clRef != null ? _clRef . get ( ) : null ; if ( cl == null ) { return false ; } /* if (cl.isAnnotationPresent(RequireReload.class)) return true; */ byte [ ] bytecode = new byte [ ( int ) length ] ; try ( InputStream is = _classPath . inputStream ( ) ) { IoUtil . readAll ( is , bytecode , 0 , bytecode . length ) ; } int result = reloadNative ( cl , bytecode , 0 , bytecode . length ) ; if ( result != 0 ) { _classIsModified = true ; return true ; } // XXX: setDependPath(_classPath); if ( _sourcePath != null ) { _sourceLastModified = _sourcePath . getLastModified ( ) ; _sourceLength = _sourcePath . length ( ) ; } log . info ( "Reloading " + cl . getName ( ) ) ; return false ; } catch ( Exception e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; _classIsModified = true ; return true ; } }
Returns true if the reload doesn t avoid the dependency .
314
11
139,807
public void load ( ByteArrayBuffer buffer ) throws IOException { synchronized ( this ) { Source classPath = getClassPath ( ) ; buffer . clear ( ) ; int retry = 3 ; for ( int i = 0 ; i < retry ; i ++ ) { long length = - 1 ; try ( InputStream is = classPath . inputStream ( ) ) { length = classPath . length ( ) ; long lastModified = classPath . getLastModified ( ) ; if ( length < 0 ) throw new IOException ( "class loading failed because class file '" + classPath + "' does not have a positive length. Possibly the file has been overwritten" ) ; buffer . setLength ( ( int ) length ) ; int results = IoUtil . readAll ( is , buffer . getBuffer ( ) , 0 , ( int ) length ) ; if ( results == length && length == classPath . length ( ) && lastModified == classPath . getLastModified ( ) ) { return ; } log . warning ( L . l ( "{0}: class file length mismatch expected={1} received={2}. The class file may have been modified concurrently." , this , length , results ) ) ; } } } }
Loads the contents of the class file into the buffer .
259
12
139,808
public static SystemManager getCurrent ( ) { SystemManager system = _systemLocal . get ( ) ; if ( system == null ) { WeakReference < SystemManager > globalRef = _globalSystemRef ; if ( globalRef != null ) { system = globalRef . get ( ) ; } } return system ; }
Returns the current server
65
4
139,809
public static < T extends SubSystem > T getCurrentSystem ( Class < T > systemClass ) { SystemManager manager = getCurrent ( ) ; if ( manager != null ) return manager . getSystem ( systemClass ) ; else return null ; }
Returns the current identified system .
51
6
139,810
public static String getCurrentId ( ) { SystemManager system = getCurrent ( ) ; if ( system == null ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; throw new IllegalStateException ( L . l ( "{0} is not available in this context.\n {1}" , SystemManager . class . getSimpleName ( ) , loader ) ) ; } return system . getId ( ) ; }
Returns the current system id .
94
6
139,811
public < T extends SubSystem > T addSystemIfAbsent ( T system ) { return addSystemIfAbsent ( system . getClass ( ) , system ) ; }
Adds a new service .
36
5
139,812
@ SuppressWarnings ( "unchecked" ) public < T extends SubSystem > T getSystem ( Class < T > cl ) { return ( T ) _systemMap . get ( cl ) ; }
Returns the system for the given class .
44
8
139,813
private void stop ( ShutdownModeAmp mode ) { _shutdownMode = mode ; Thread thread = Thread . currentThread ( ) ; ClassLoader oldLoader = thread . getContextClassLoader ( ) ; try { thread . setContextClassLoader ( _classLoader ) ; if ( ! _lifecycle . toStopping ( ) ) { return ; } TreeSet < SubSystem > systems = new TreeSet < SubSystem > ( new StopComparator ( ) ) ; systems . addAll ( _systemMap . values ( ) ) ; // sort for ( SubSystem system : systems ) { try { thread . setContextClassLoader ( _classLoader ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( system + " stopping" ) ; } system . stop ( mode ) ; } catch ( Throwable e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } } } finally { _lifecycle . toStop ( ) ; thread . setContextClassLoader ( oldLoader ) ; } }
stops the server .
224
5
139,814
public void shutdown ( ShutdownModeAmp mode ) { stop ( mode ) ; if ( ! _lifecycle . toDestroy ( ) ) { return ; } Thread thread = Thread . currentThread ( ) ; ClassLoader oldLoader = thread . getContextClassLoader ( ) ; try { thread . setContextClassLoader ( _classLoader ) ; TreeSet < SubSystem > systems = new TreeSet < SubSystem > ( new StopComparator ( ) ) ; systems . addAll ( _systemMap . values ( ) ) ; _systemMap . clear ( ) ; for ( SubSystem system : systems ) { try { system . destroy ( ) ; } catch ( Throwable e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } } WeakReference < SystemManager > globalRef = _globalSystemRef ; if ( globalRef != null && globalRef . get ( ) == this ) { _globalSystemRef = null ; } /* * destroy */ log . fine ( this + " destroyed" ) ; _classLoader . destroy ( ) ; } finally { // DynamicClassLoader.setOldLoader(thread, oldLoader); thread . setContextClassLoader ( oldLoader ) ; _classLoader = null ; } }
Shuts down the server in the given mode .
259
10
139,815
public boolean addProperty ( String propertyName , String property ) { boolean ret = this . properties . containsKey ( propertyName ) ; this . properties . put ( propertyName , property ) ; return ret ; }
Used to add a new property to the offering
43
9
139,816
public static String sanitizeName ( String name ) { if ( name == null ) throw new NullPointerException ( "Parameter name cannot be null" ) ; name = name . trim ( ) ; if ( name . length ( ) == 0 ) throw new IllegalArgumentException ( "Parameter name cannot be empty" ) ; StringBuilder ret = new StringBuilder ( "" ) ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { char ch = name . charAt ( i ) ; if ( Character . isLetter ( ch ) || Character . isDigit ( ch ) ) { ret . append ( ch ) ; } else { ret . append ( "_" ) ; } } return ret . toString ( ) ; }
Sanitizes a name by replacing every not alphanumeric character with _
158
15
139,817
public String getUtf8AsString ( int index ) { Utf8Constant utf8 = ( Utf8Constant ) _entries . get ( index ) ; if ( utf8 == null ) return null ; else return utf8 . getValue ( ) ; }
Returns a utf - 8 constant as a string
61
10
139,818
public void addConstant ( ConstantPoolEntry entry ) { if ( entry instanceof Utf8Constant ) { Utf8Constant utf8 = ( Utf8Constant ) entry ; _utf8Map . put ( utf8 . getValue ( ) , utf8 ) ; } _entries . add ( entry ) ; }
Adds a new constant .
74
5
139,819
public Utf8Constant addUTF8 ( String value ) { Utf8Constant entry = getUTF8 ( value ) ; if ( entry != null ) return entry ; entry = new Utf8Constant ( this , _entries . size ( ) , value ) ; addConstant ( entry ) ; return entry ; }
Adds a UTF - 8 constant .
70
7
139,820
public StringConstant getString ( String name ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof StringConstant ) ) continue ; StringConstant stringEntry = ( StringConstant ) entry ; if ( stringEntry . getString ( ) . equals ( name ) ) return stringEntry ; } return null ; }
Gets a string constant .
97
6
139,821
public StringConstant addString ( String name ) { StringConstant entry = getString ( name ) ; if ( entry != null ) { return entry ; } Utf8Constant utf8 = addUTF8 ( name ) ; entry = new StringConstant ( this , _entries . size ( ) , utf8 . getIndex ( ) ) ; addConstant ( entry ) ; return entry ; }
Adds a string constant .
87
5
139,822
public IntegerConstant getIntegerByValue ( int value ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof IntegerConstant ) ) continue ; IntegerConstant integerEntry = ( IntegerConstant ) entry ; if ( integerEntry . getValue ( ) == value ) return integerEntry ; } return null ; }
Gets a integer constant .
96
6
139,823
public IntegerConstant addInteger ( int value ) { IntegerConstant entry = getIntegerByValue ( value ) ; if ( entry != null ) return entry ; entry = new IntegerConstant ( this , _entries . size ( ) , value ) ; addConstant ( entry ) ; return entry ; }
Adds a integer constant .
64
5
139,824
public LongConstant getLongByValue ( long value ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof LongConstant ) ) continue ; LongConstant longEntry = ( LongConstant ) entry ; if ( longEntry . getValue ( ) == value ) return longEntry ; } return null ; }
Gets a long constant .
96
6
139,825
public LongConstant addLong ( long value ) { LongConstant entry = getLongByValue ( value ) ; if ( entry != null ) return entry ; entry = new LongConstant ( this , _entries . size ( ) , value ) ; addConstant ( entry ) ; addConstant ( null ) ; return entry ; }
Adds a long constant .
71
5
139,826
public FloatConstant getFloatByValue ( float value ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof FloatConstant ) ) continue ; FloatConstant floatEntry = ( FloatConstant ) entry ; if ( floatEntry . getValue ( ) == value ) return floatEntry ; } return null ; }
Gets a float constant .
96
6
139,827
public FloatConstant addFloat ( float value ) { FloatConstant entry = getFloatByValue ( value ) ; if ( entry != null ) return entry ; entry = new FloatConstant ( this , _entries . size ( ) , value ) ; addConstant ( entry ) ; return entry ; }
Adds a float constant .
64
5
139,828
public DoubleConstant getDoubleByValue ( double value ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof DoubleConstant ) ) continue ; DoubleConstant doubleEntry = ( DoubleConstant ) entry ; if ( doubleEntry . getValue ( ) == value ) return doubleEntry ; } return null ; }
Gets a double constant .
96
6
139,829
public DoubleConstant addDouble ( double value ) { DoubleConstant entry = getDoubleByValue ( value ) ; if ( entry != null ) return entry ; entry = new DoubleConstant ( this , _entries . size ( ) , value ) ; addConstant ( entry ) ; addConstant ( null ) ; return entry ; }
Adds a double constant .
71
5
139,830
public ClassConstant getClass ( String name ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof ClassConstant ) ) continue ; ClassConstant classEntry = ( ClassConstant ) entry ; if ( classEntry . getName ( ) . equals ( name ) ) return classEntry ; } return null ; }
Gets a class constant .
97
6
139,831
public ClassConstant addClass ( String name ) { ClassConstant entry = getClass ( name ) ; if ( entry != null ) return entry ; Utf8Constant utf8 = addUTF8 ( name ) ; entry = new ClassConstant ( this , _entries . size ( ) , utf8 . getIndex ( ) ) ; addConstant ( entry ) ; return entry ; }
Adds a class constant .
85
5
139,832
public NameAndTypeConstant getNameAndType ( String name , String type ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof NameAndTypeConstant ) ) continue ; NameAndTypeConstant methodEntry = ( NameAndTypeConstant ) entry ; if ( methodEntry . getName ( ) . equals ( name ) && methodEntry . getType ( ) . equals ( type ) ) return methodEntry ; } return null ; }
Gets a name - and - type constant .
123
10
139,833
public NameAndTypeConstant addNameAndType ( String name , String type ) { NameAndTypeConstant entry = getNameAndType ( name , type ) ; if ( entry != null ) return entry ; Utf8Constant nameEntry = addUTF8 ( name ) ; Utf8Constant typeEntry = addUTF8 ( type ) ; entry = new NameAndTypeConstant ( this , _entries . size ( ) , nameEntry . getIndex ( ) , typeEntry . getIndex ( ) ) ; addConstant ( entry ) ; return entry ; }
Adds a name - and - type constant .
121
9
139,834
public FieldRefConstant addFieldRef ( String className , String name , String type ) { FieldRefConstant entry = getFieldRef ( className , name , type ) ; if ( entry != null ) return entry ; ClassConstant classEntry = addClass ( className ) ; NameAndTypeConstant typeEntry = addNameAndType ( name , type ) ; entry = new FieldRefConstant ( this , _entries . size ( ) , classEntry . getIndex ( ) , typeEntry . getIndex ( ) ) ; addConstant ( entry ) ; return entry ; }
Adds a field ref constant .
124
6
139,835
public MethodHandleConstant getMethodHandle ( MethodHandleType mhType , ConstantPoolEntry cpEntry ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof MethodHandleConstant ) ) { continue ; } MethodHandleConstant methodHandle = ( MethodHandleConstant ) entry ; if ( methodHandle . getType ( ) . equals ( mhType ) && methodHandle . getConstantEntry ( ) . equals ( cpEntry ) ) { return methodHandle ; } } return null ; }
Gets a method ref constant .
134
7
139,836
public InterfaceMethodRefConstant getInterfaceRef ( String className , String name , String type ) { for ( int i = 0 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( ! ( entry instanceof InterfaceMethodRefConstant ) ) continue ; InterfaceMethodRefConstant methodEntry ; methodEntry = ( InterfaceMethodRefConstant ) entry ; if ( methodEntry . getClassName ( ) . equals ( className ) && methodEntry . getName ( ) . equals ( name ) && methodEntry . getType ( ) . equals ( type ) ) return methodEntry ; } return null ; }
Gets an interface constant .
144
6
139,837
public InterfaceMethodRefConstant addInterfaceRef ( String className , String name , String type ) { InterfaceMethodRefConstant entry = getInterfaceRef ( className , name , type ) ; if ( entry != null ) return entry ; ClassConstant classEntry = addClass ( className ) ; NameAndTypeConstant typeEntry = addNameAndType ( name , type ) ; entry = new InterfaceMethodRefConstant ( this , _entries . size ( ) , classEntry . getIndex ( ) , typeEntry . getIndex ( ) ) ; addConstant ( entry ) ; return entry ; }
Adds an interface ref constant .
127
6
139,838
public InvokeDynamicConstant addInvokeDynamicRef ( BootstrapMethodAttribute attr , String methodName , String methodType , String bootClass , String bootMethod , String bootType , ConstantPoolEntry [ ] cpEntries ) { NameAndTypeConstant methodEntry = addNameAndType ( methodName , methodType ) ; MethodRefConstant bootMethodRef = addMethodRef ( bootClass , bootMethod , bootType ) ; MethodHandleConstant bootMethodHandle = addMethodHandle ( MethodHandleType . INVOKE_STATIC , bootMethodRef ) ; int bootIndex = attr . addMethod ( bootMethodHandle . getIndex ( ) , cpEntries ) ; InvokeDynamicConstant invokedynamicRef = new InvokeDynamicConstant ( this , _entries . size ( ) , attr , bootIndex , methodEntry . getIndex ( ) ) ; addConstant ( invokedynamicRef ) ; return invokedynamicRef ; }
Adds an invokedynamic constant .
199
6
139,839
public void write ( ByteCodeWriter out ) throws IOException { out . writeShort ( _entries . size ( ) ) ; for ( int i = 1 ; i < _entries . size ( ) ; i ++ ) { ConstantPoolEntry entry = _entries . get ( i ) ; if ( entry != null ) entry . write ( out ) ; } }
Writes the contents of the pool .
77
8
139,840
public void write ( int b ) throws IOException { log . info ( "random-write(0x" + Long . toHexString ( getFilePointer ( ) ) + ",1)" ) ; _file . write ( b ) ; }
Write a byte to the file advancing the pointer .
53
10
139,841
private Topology createAdHocTopologyFromSuitableOptions ( SuitableOptions appInfoSuitableOptions ) { Topology topology = new Topology ( ) ; TopologyElement current = null ; TopologyElement previous = null ; for ( String moduleName : appInfoSuitableOptions . getStringIterator ( ) ) { if ( current == null ) { // first element treated. None of them needs to point at it current = new TopologyElement ( moduleName ) ; topology . addModule ( current ) ; } else { // There were explored already other modules previous = current ; current = new TopologyElement ( moduleName ) ; previous . addElementCalled ( current ) ; topology . addModule ( current ) ; } } return topology ; }
Later it will be better an exception than a weird result .
159
12
139,842
public int read ( byte [ ] buffer , int offset , int length ) throws IOException { int len = _next . read ( buffer , offset , length ) ; _crc = Crc64 . generate ( _crc , buffer , offset , len ) ; return len ; }
Reads a buffer from the underlying stream .
59
9
139,843
public void removeDirectory ( String path , String tail , Result < Object > result ) { // _dirRemove.exec(result, path, tail); result . ok ( null ) ; }
Updates the directory with the new file list .
39
10
139,844
void updateRack ( HeartbeatImpl heartbeat , UpdateRackHeartbeat updateRack ) { for ( UpdateServerHeartbeat serverUpdate : updateRack . getServers ( ) ) { if ( serverUpdate == null ) { continue ; } update ( serverUpdate ) ; // updateTargetServers(); ServerHeartbeat peerServer = findServer ( serverUpdate . getAddress ( ) , serverUpdate . getPort ( ) ) ; if ( peerServer . isSelf ( ) ) { continue ; } heartbeat . updateServer ( peerServer , serverUpdate ) ; /* String externalId = serverUpdate.getExternalId(); heartbeat.updateExternal(peerServer, externalId); if (peerServer.onHeartbeatUpdate(serverUpdate)) { if (peerServer.isUp()) { onServerStart(peerServer); } else { onServerStop(peerServer); } } */ } update ( ) ; }
Update the rack with a heartbeat message .
187
8
139,845
@ Override public String get ( String key , String defaultValue ) { String value = _map . get ( key ) ; if ( value != null ) { return value ; } else { return defaultValue ; } }
Configuration value with a default value .
45
7
139,846
@ SuppressWarnings ( "unchecked" ) public < T > T get ( String key , Class < T > type , T defaultValue ) { Objects . requireNonNull ( key ) ; Objects . requireNonNull ( type ) ; String value = _map . get ( key ) ; if ( value == null ) { return defaultValue ; } if ( type . equals ( String . class ) ) { return ( T ) value ; } T valueType = _converter . convert ( type , value ) ; if ( valueType != null ) { return valueType ; } else { log . warning ( L . l ( "Unexpected type for key={0} type={1} value={2}" , key , type , value ) ) ; /* throw new ConfigException(L.l("Unexpected type for key={0} type={1} value={2}", key, type, value)); */ return defaultValue ; } }
Gets a configuration value converted to a type .
198
10
139,847
@ Override public < T > void inject ( T bean , String prefix ) { Objects . requireNonNull ( bean ) ; ConfigStub stub = new ConfigStub ( bean . getClass ( ) , prefix ) ; stub . inject ( bean , this ) ; }
Inject a bean from the configuration
56
7
139,848
private static void readChar ( ByteToChar converter , CharReader is , int ch , boolean isTop ) throws IOException { if ( ch == ' ' ) { if ( isTop ) converter . addByte ( ' ' ) ; else converter . addChar ( ' ' ) ; } else if ( ch == ' ' ) { int ch1 = is . next ( ) ; if ( ch1 == ' ' ) { ch1 = is . next ( ) ; int ch2 = is . next ( ) ; int ch3 = is . next ( ) ; int ch4 = is . next ( ) ; converter . addChar ( ( char ) ( ( toHex ( ch1 ) << 12 ) + ( toHex ( ch2 ) << 8 ) + ( toHex ( ch3 ) << 4 ) + ( toHex ( ch4 ) ) ) ) ; } else { int ch2 = is . next ( ) ; converter . addByte ( ( ( toHex ( ch1 ) << 4 ) + toHex ( ch2 ) ) ) ; } } else if ( isTop ) { converter . addByte ( ( byte ) ch ) ; } else { converter . addChar ( ( char ) ch ) ; } }
Scans the next character from the input stream adding it to the converter .
260
15
139,849
@ Override public void run ( ) { try { runImpl ( ) ; } catch ( final Throwable e ) { // env/0203 vs env/0206 if ( e instanceof DisplayableException ) log . warning ( e . getMessage ( ) ) ; else log . warning ( e . toString ( ) ) ; _exception = e ; } finally { notifyComplete ( ) ; } }
runs the compiler .
85
4
139,850
@ Override public void write ( int v ) throws IOException { _buf [ 0 ] = ( byte ) v ; _stream . write ( _buf , 0 , 1 , false ) ; }
Writes a byte to the underlying stream .
41
9
139,851
public static String getLocation ( String providerName ) { for ( String key : map . keySet ( ) ) { if ( providerName . startsWith ( key ) ) { return map . get ( key ) ; } } return null ; }
Gets the sanitized location of an offering
50
9
139,852
public void read ( ByteCodeParser in ) throws IOException { int length = in . readInt ( ) ; if ( length != 2 ) throw new IOException ( "expected length of 2 at " + length ) ; int code = in . readShort ( ) ; _signature = in . getUTF8 ( code ) ; }
Reads the signature .
69
5
139,853
public void write ( String s , int offset , int length ) throws IOException { while ( length > 0 ) { if ( _tail == null ) addBuffer ( TempCharBuffer . allocate ( ) ) ; else if ( _tail . _buf . length <= _tail . _length ) { addBuffer ( TempCharBuffer . allocate ( ) ) ; // XXX: see TempStream for backing files } int sublen = _tail . _buf . length - _tail . _length ; if ( length < sublen ) sublen = length ; s . getChars ( offset , offset + sublen , _tail . _buf , _tail . _length ) ; offset += sublen ; length -= sublen ; _tail . _length += sublen ; } }
Writes part of a string .
160
7
139,854
private static ClassLoader getInitParent ( ClassLoader parent , boolean isRoot ) { if ( parent == null ) parent = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( isRoot || parent instanceof DynamicClassLoader ) return parent ; else { //return RootDynamicClassLoader.create(parent); return parent ; } }
Returns the initialization parent i . e . the parent if given or the context class loader if not given .
72
21
139,855
@ Override public void write ( int ch ) throws IOException { char [ ] buffer = _tempCharBuffer ; buffer [ 0 ] = ( char ) ch ; write ( buffer , 0 , 1 ) ; }
Writes a character to the output .
44
8
139,856
@ Override public void write ( String s , int off , int len ) throws IOException { char [ ] buffer = _tempCharBuffer ; int bufferLength = buffer . length ; while ( len > 0 ) { int sublen = Math . min ( len , bufferLength ) ; s . getChars ( off , off + sublen , buffer , 0 ) ; write ( buffer , 0 , sublen ) ; off += sublen ; len -= sublen ; } }
Writes a subsection of a string to the output .
99
11
139,857
@ Override final public void write ( String s ) throws IOException { if ( s == null ) { write ( _nullChars , 0 , _nullChars . length ) ; return ; } write ( s , 0 , s . length ( ) ) ; }
Writes a string to the output .
56
8
139,858
public HeaderParams put ( String name , String value ) { values . put ( cleanAndValidate ( name ) , cleanAndValidate ( value ) ) ; return this ; }
Overwrites in case there is a value already associated with that name .
38
15
139,859
public void setBackgroundPeriod ( long period ) { if ( period < 1 ) { throw new ConfigException ( L . l ( "profile period '{0}ms' is too small. The period must be greater than 10ms." , period ) ) ; } _profilerService . setBackgroundInterval ( period , TimeUnit . MILLISECONDS ) ; }
Sets the background interval . If the background profile hasn t started start it .
78
16
139,860
public void setLocation ( String filename , int line ) throws IOException { if ( _lineMap != null && filename != null && line >= 0 ) { _lineMap . add ( filename , line , _destLine , _isPreferLast ) ; } }
Sets the source filename and line .
55
8
139,861
public void print ( String s ) throws IOException { if ( _startLine ) printIndent ( ) ; if ( s == null ) { _lastCr = false ; _os . print ( "null" ) ; return ; } int len = s . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { int ch = s . charAt ( i ) ; if ( ch == ' ' && ! _lastCr ) _destLine ++ ; else if ( ch == ' ' ) _destLine ++ ; _lastCr = ch == ' ' ; _os . print ( ( char ) ch ) ; } }
Prints a string
136
4
139,862
public void print ( char ch ) throws IOException { if ( _startLine ) printIndent ( ) ; if ( ch == ' ' ) { _destLine ++ ; } else if ( ch == ' ' && ! _lastCr ) _destLine ++ ; _lastCr = ch == ' ' ; _os . print ( ch ) ; }
Prints a character .
73
5
139,863
public void print ( boolean b ) throws IOException { if ( _startLine ) printIndent ( ) ; _os . print ( b ) ; _lastCr = false ; }
Prints a boolean .
38
5
139,864
public void print ( long l ) throws IOException { if ( _startLine ) printIndent ( ) ; _os . print ( l ) ; _lastCr = false ; }
Prints an long
38
4
139,865
public void print ( Object o ) throws IOException { if ( _startLine ) printIndent ( ) ; _os . print ( o ) ; _lastCr = false ; }
Prints an object .
38
5
139,866
public void println ( ) throws IOException { _os . println ( ) ; if ( ! _lastCr ) _destLine ++ ; _lastCr = false ; _startLine = true ; }
Prints a newline
41
5
139,867
public void printClass ( Class < ? > cl ) throws IOException { if ( ! cl . isArray ( ) ) print ( cl . getName ( ) . replace ( ' ' , ' ' ) ) ; else { printClass ( cl . getComponentType ( ) ) ; print ( "[]" ) ; } }
Prints the Java represention of the class
66
10
139,868
@ SuppressWarnings ( "unchecked" ) public void printType ( Type type ) throws IOException { if ( type instanceof Class < ? > ) { printTypeClass ( ( Class < ? > ) type ) ; } else if ( type instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; printParameterizedType ( parameterizedType ) ; } else if ( type instanceof WildcardType ) { WildcardType wildcardType = ( WildcardType ) type ; printWildcardType ( wildcardType ) ; } else if ( type instanceof TypeVariable < ? > ) { TypeVariable < ? extends GenericDeclaration > typeVariable = ( TypeVariable < ? extends GenericDeclaration > ) type ; printTypeVariable ( typeVariable ) ; } else if ( type instanceof GenericArrayType ) { GenericArrayType genericArrayType = ( GenericArrayType ) type ; printType ( genericArrayType . getGenericComponentType ( ) ) ; print ( "[]" ) ; } else { throw new UnsupportedOperationException ( type . getClass ( ) . getName ( ) + " " + String . valueOf ( type ) ) ; } }
Prints the Java representation of the type
253
8
139,869
public void printIndent ( ) throws IOException { _startLine = false ; for ( int i = 0 ; i < _indentDepth ; i ++ ) _os . print ( ' ' ) ; _lastCr = false ; }
Prints the indentation at the beginning of a line .
50
12
139,870
public static Parameter getActionParameter ( Action action , String paramName ) { for ( Parameter param : action . getParameters ( ) ) { if ( paramName . equals ( param . getName ( ) ) ) { return param ; } } return NOT_FOUND_PARAMETER ; }
Returns the first parameter with attribute name equals to paramName ; if not found NOT_FOUND_PARAMETER .
63
25
139,871
public static List < Action > getActions ( MonitoringRule rule , String nameFilter ) { List < Action > result = new ArrayList < Action > ( ) ; if ( nameFilter == null ) { throw new NullPointerException ( "nameFilter cannot be null" ) ; } for ( Action action : getActions ( rule ) ) { if ( nameFilter . equalsIgnoreCase ( action . getName ( ) ) ) { result . add ( action ) ; } } return result ; }
Get the actions of a rule filtered by its name
104
10
139,872
public static List < Action > getActions ( MonitoringRule rule ) { List < Action > result ; if ( rule . getActions ( ) != null && rule . getActions ( ) . getActions ( ) != null ) { result = rule . getActions ( ) . getActions ( ) ; } else { result = Collections . < Action > emptyList ( ) ; } return result ; }
Wrapper to avoid a NPE
86
7
139,873
public static ObjectName getObjectName ( String domain , Map < String , String > properties ) throws MalformedObjectNameException { StringBuilder cb = new StringBuilder ( ) ; cb . append ( domain ) ; cb . append ( ' ' ) ; boolean isFirst = true ; Pattern escapePattern = Pattern . compile ( "[,=:\"*?]" ) ; // sort type first String type = properties . get ( "type" ) ; if ( type != null ) { cb . append ( "type=" ) ; if ( escapePattern . matcher ( type ) . find ( ) ) type = ObjectName . quote ( type ) ; cb . append ( type ) ; isFirst = false ; } for ( String key : properties . keySet ( ) ) { if ( key . equals ( "type" ) ) { continue ; } if ( ! isFirst ) cb . append ( ' ' ) ; isFirst = false ; cb . append ( key ) ; cb . append ( ' ' ) ; String value = properties . get ( key ) ; if ( value == null ) { throw new NullPointerException ( String . valueOf ( key ) ) ; } if ( value . length ( ) == 0 || ( escapePattern . matcher ( value ) . find ( ) && ! ( value . startsWith ( "\"" ) && value . endsWith ( "\"" ) ) ) ) { value = ObjectName . quote ( value ) ; } cb . append ( value ) ; } return new ObjectName ( cb . toString ( ) ) ; }
Creates the clean name
333
5
139,874
private boolean isMethodApi ( Method method ) { if ( _type == _api ) { return true ; } for ( Method methodApi : _api . getMethods ( ) ) { if ( methodApi . getName ( ) . equals ( method . getName ( ) ) ) { return true ; } } return false ; }
Only API methods are exposed .
71
6
139,875
@ Override public StateConnection service ( ) { try { StateConnection nextState = _state . service ( this ) ; //return StateConnection.CLOSE; return nextState ; /* if (_invocation == null && getRequestHttp().parseInvocation()) { if (_invocation == null) { return NextState.CLOSE; } return _invocation.service(this, getResponse()); } else if (_upgrade != null) { return _upgrade.service(); } else if (_invocation != null) { return _invocation.service(this); } else { return StateConnection.CLOSE; } */ } catch ( Throwable e ) { log . warning ( e . toString ( ) ) ; log . log ( Level . FINER , e . toString ( ) , e ) ; //e.printStackTrace(); toClose ( ) ; return StateConnection . CLOSE_READ_A ; } }
Service is the main call when data is available from the socket .
192
13
139,876
@ Override public void exec ( String sql , Result < Object > result , Object ... args ) { _kraken . query ( sql ) . exec ( result , args ) ; }
Executes a command against the database .
39
8
139,877
@ Override public void prepare ( String sql , Result < CursorPrepareSync > result ) { result . ok ( _kraken . query ( sql ) . prepare ( ) ) ; }
Prepares for later execution of a command .
41
9
139,878
@ Override public void findOne ( String sql , Result < Cursor > result , Object ... args ) { _kraken . query ( sql ) . findOne ( result , args ) ; }
Queries for a single result in the database .
42
10
139,879
public void find ( ResultStream < Cursor > result , String sql , Object ... args ) { _kraken . findStream ( sql , args , result ) ; }
Queries the database returning values to a result sink .
36
11
139,880
@ Override public void map ( MethodRef method , String sql , Object ... args ) { _kraken . map ( method , sql , args ) ; }
Starts a map call on the local node .
34
10
139,881
public void writeAttribute ( String name , Object value ) { if ( ! _isElementOpen ) throw new IllegalStateException ( "no open element" ) ; if ( value == null ) return ; _isElementOpen = false ; try { _strategy . writeAttribute ( this , name , value ) ; } finally { _isElementOpen = true ; } }
Write an attribute with a value if value is null nothing is written .
76
14
139,882
public void writeAttribute ( String name , Object ... values ) { if ( ! _isElementOpen ) throw new IllegalStateException ( "no open element" ) ; _isElementOpen = false ; try { _strategy . writeAttribute ( this , name , values ) ; } finally { _isElementOpen = true ; } }
Write an attribute with multiple values separated by space if a value is null nothing is written .
69
18
139,883
public void requestPubkey ( final BitmessageAddress contact ) { BitmessageAddress stored = addressRepository . getAddress ( contact . getAddress ( ) ) ; tryToFindMatchingPubkey ( contact ) ; if ( contact . getPubkey ( ) != null ) { if ( stored != null ) { stored . setPubkey ( contact . getPubkey ( ) ) ; addressRepository . save ( stored ) ; } else { addressRepository . save ( contact ) ; } return ; } if ( stored == null ) { addressRepository . save ( contact ) ; } long expires = UnixTime . now ( TTL . getpubkey ( ) ) ; LOG . info ( "Expires at " + expires ) ; final ObjectMessage request = new ObjectMessage . Builder ( ) . stream ( contact . getStream ( ) ) . expiresTime ( expires ) . payload ( new GetPubkey ( contact ) ) . build ( ) ; proofOfWorkService . doProofOfWork ( request ) ; }
Be aware that if the pubkey already exists in the inventory the metods will not request it and the callback for freshly received pubkeys will not be called . Instead the pubkey is added to the contact and stored on DB .
209
46
139,884
public void addForeignWatch ( TableKraken table , byte [ ] key , String serverId ) { WatchForeign watch = new WatchForeign ( key , table , serverId ) ; WatchTable watchTable = getWatchTable ( table ) ; watchTable . addWatchForeign ( watch , key ) ; }
Adds a watch from a foreign server . Remote notifications will send a copy to the foreign server .
63
19
139,885
@ Override public void notifyWatch ( TableKraken table , byte [ ] key ) { WatchTable watchTable = _tableMap . get ( table ) ; if ( watchTable != null ) { watchTable . onPut ( key , TableListener . TypePut . REMOTE ) ; } }
Notify local and remote watches for the given table and key
62
12
139,886
public void notifyLocalWatch ( TableKraken table , byte [ ] key ) { WatchTable watchTable = _tableMap . get ( table ) ; if ( watchTable != null ) { watchTable . onPut ( key , TableListener . TypePut . LOCAL ) ; } }
Notify local watches for the given table and key
60
10
139,887
public void addTable ( TableKelp tableKelp , String sql , BackupKelp backupCb ) { // TableKelp tableKelp = tableKraken.getTableKelp(); RowCursor cursor = _metaTable . cursor ( ) ; cursor . setBytes ( 1 , tableKelp . tableKey ( ) , 0 ) ; cursor . setString ( 2 , tableKelp . getName ( ) ) ; cursor . setString ( 3 , sql ) ; //BackupCallback backupCb = _metaTable.getBackupCallback(); //_metaTable.getTableKelp().put(cursor, backupCb, // new CreateTableCompletion(tableKraken, result)); // _metaTable.getTableKelp().put(cursor, backupCb, // result.from(v->tableKraken)); _metaTable . put ( cursor , backupCb , Result . ignore ( ) ) ; // tableKraken.start(); }
Table callbacks .
219
4
139,888
public void write ( byte [ ] buffer , int offset , int length ) throws IOException { _file . write ( buffer , offset , length ) ; }
Writes a block starting from the current file pointer .
32
11
139,889
public void write ( long fileOffset , byte [ ] buffer , int offset , int length ) throws IOException { _file . seek ( fileOffset ) ; _file . write ( buffer , offset , length ) ; }
Writes a block from a given location .
45
9
139,890
public OutputStream getOutputStream ( ) throws IOException { if ( _os == null ) _os = new FileOutputStream ( _file . getFD ( ) ) ; return _os ; }
Returns an OutputStream for this stream .
41
8
139,891
public InputStream getInputStream ( ) throws IOException { if ( _is == null ) _is = new FileInputStream ( _file . getFD ( ) ) ; return _is ; }
Returns an InputStream for this stream .
41
8
139,892
public static String encodeString ( String uri ) { CharBuffer cb = CharBuffer . allocate ( ) ; for ( int i = 0 ; i < uri . length ( ) ; i ++ ) { char ch = uri . charAt ( i ) ; switch ( ch ) { case ' ' : cb . append ( "&lt;" ) ; break ; case ' ' : cb . append ( "&gt;" ) ; break ; case ' ' : cb . append ( "&amp;" ) ; break ; default : cb . append ( ch ) ; } } return cb . close ( ) ; }
Escape special characters .
132
5
139,893
public double getLatencyFactor ( ) { long now = CurrentTime . currentTime ( ) ; long decayPeriod = 60000 ; long delta = decayPeriod - ( now - _lastSuccessTime ) ; // decay the latency factor over 60s if ( delta <= 0 ) return 0 ; else return ( _latencyFactor * delta ) / decayPeriod ; }
Returns the latency factory
77
4
139,894
public double getCpuLoadAvg ( ) { double avg = _cpuLoadAvg ; long time = _cpuSetTime ; long now = CurrentTime . currentTime ( ) ; if ( now - time < 10000L ) return avg ; else return avg * 10000L / ( now - time ) ; }
Gets the CPU load avg
63
6
139,895
@ Override public void success ( ) { _currentFailCount = 0 ; long now = CurrentTime . currentTime ( ) ; if ( _firstSuccessTime <= 0 ) { _firstSuccessTime = now ; } // reset the connection fail recover time _dynamicFailRecoverTime = 1000L ; }
Called when the server has a successful response
64
9
139,896
@ Override public ClientSocket openWarm ( ) { State state = _state ; if ( ! state . isEnabled ( ) ) { return null ; } /* long now = CurrentTime.getCurrentTime(); if (isFailed(now)) { return null; } */ ClientSocket stream = openRecycle ( ) ; if ( stream != null ) { return stream ; } if ( canOpenWarm ( ) ) { return connect ( ) ; } else { return null ; } }
Open a stream to the target server restricted by warmup .
101
12
139,897
@ Override public ClientSocket openIfLive ( ) { if ( _state . isClosed ( ) ) { return null ; } ClientSocket stream = openRecycle ( ) ; if ( stream != null ) return stream ; long now = CurrentTime . currentTime ( ) ; if ( isFailed ( now ) ) return null ; else if ( _state == State . FAIL && _startingCount . get ( ) > 0 ) { // if in fail state, only one thread should try to connect return null ; } return connect ( ) ; }
Open a stream to the target server object persistence .
115
10
139,898
public ClientSocket openIfHeartbeatActive ( ) { if ( _state . isClosed ( ) ) { return null ; } if ( ! _isHeartbeatActive && _isHeartbeatServer ) { return null ; } ClientSocket stream = openRecycle ( ) ; if ( stream != null ) return stream ; return connect ( ) ; }
Open a stream if the target server s heartbeat is active .
72
12
139,899
public ClientSocket openSticky ( ) { State state = _state ; if ( ! state . isSessionEnabled ( ) ) { return null ; } ClientSocket stream = openRecycle ( ) ; if ( stream != null ) return stream ; long now = CurrentTime . currentTime ( ) ; if ( isFailed ( now ) ) { return null ; } if ( isBusy ( now ) ) { return null ; } return connect ( ) ; }
Open a stream to the target server for a session .
95
11