idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
13,300
private void registerConnectivityReceiver ( ) { IntentFilter intentFilter = new IntentFilter ( ) ; intentFilter . addAction ( ConnectivityManager . CONNECTIVITY_ACTION ) ; context . registerReceiver ( connectivityReceiver , intentFilter ) ; }
Registers receiver to be notified of broadcast event when network connection changes
13,301
public boolean isWifiFake ( String ipAddress , int port ) { SocketChannel socketChannel = null ; try { socketChannel = SocketChannel . open ( ) ; socketChannel . connect ( new InetSocketAddress ( ipAddress , port ) ) ; } catch ( IOException e ) { Log . d ( TAG , "Current Wifi is stupid!!! by IOException" ) ; return true ; } catch ( UnresolvedAddressException e ) { Log . d ( TAG , "Current Wifi is stupid!!! by InetSocketAddress" ) ; return true ; } finally { if ( socketChannel != null ) try { socketChannel . close ( ) ; } catch ( IOException e ) { Log . d ( TAG , "Error occured while closing SocketChannel" ) ; } } return false ; }
Checks if currently connected Access Point is either rogue or incapable of routing packet
13,302
public final Object instantiateItem ( final ViewGroup container , final int position ) { if ( Constants . DEBUG ) { Log . i ( "InfiniteViewPager" , String . format ( "instantiating position %s" , position ) ) ; } final PageModel < T > model = createPageModel ( position ) ; mPageModels [ position ] = model ; container . addView ( model . getParentView ( ) ) ; return model ; }
This method is only called when this pagerAdapter is initialized .
13,303
private void printPageModels ( final String tag ) { for ( int i = 0 ; i < PAGE_COUNT ; i ++ ) { printPageModel ( tag , mPageModels [ i ] , i ) ; } }
Debug related methods
13,304
public final Position predict ( double distanceKm , double courseDegrees ) { assertWithMsg ( alt == 0.0 , "Predictions only valid for Earth's surface" ) ; double dr = distanceKm / EARTH_RADIUS_KM ; double latR = toRadians ( lat ) ; double lonR = toRadians ( lon ) ; double courseR = toRadians ( courseDegrees ) ; double lat2Radians = asin ( sin ( latR ) * cos ( dr ) + cos ( latR ) * sin ( dr ) * cos ( courseR ) ) ; double lon2Radians = atan2 ( sin ( courseR ) * sin ( dr ) * cos ( latR ) , cos ( dr ) - sin ( latR ) * sin ( lat2Radians ) ) ; double lon3Radians = mod ( lonR + lon2Radians + PI , 2 * PI ) - PI ; return new Position ( FastMath . toDegrees ( lat2Radians ) , FastMath . toDegrees ( lon3Radians ) ) ; }
Predicts position travelling along a great circle arc based on the Haversine formula .
13,305
public final double getBearingDegrees ( Position position ) { double lat1 = toRadians ( lat ) ; double lat2 = toRadians ( position . lat ) ; double lon1 = toRadians ( lon ) ; double lon2 = toRadians ( position . lon ) ; double dLon = lon2 - lon1 ; double sinDLon = sin ( dLon ) ; double cosLat2 = cos ( lat2 ) ; double y = sinDLon * cosLat2 ; double x = cos ( lat1 ) * sin ( lat2 ) - sin ( lat1 ) * cosLat2 * cos ( dLon ) ; double course = FastMath . toDegrees ( atan2 ( y , x ) ) ; if ( course < 0 ) course += 360 ; return course ; }
Returns a great circle bearing in degrees in the range 0 to 360 .
13,306
public static double getBearingDifferenceDegrees ( double bearing1 , double bearing2 ) { if ( bearing1 < 0 ) bearing1 += 360 ; if ( bearing2 > 180 ) bearing2 -= 360 ; double result = bearing1 - bearing2 ; if ( result > 180 ) result -= 360 ; return result ; }
returns difference in degrees in the range - 180 to 180
13,307
public final Position getPositionAlongPath ( Position position , double proportion ) { if ( proportion >= 0 && proportion <= 1 ) { double courseDegrees = this . getBearingDegrees ( position ) ; double distanceKm = this . getDistanceToKm ( position ) ; Position retPosition = this . predict ( proportion * distanceKm , courseDegrees ) ; return retPosition ; } else throw new RuntimeException ( "Proportion must be between 0 and 1 inclusive" ) ; }
Returns a position along a path according to the proportion value
13,308
public static double longitudeDiff ( double a , double b ) { a = to180 ( a ) ; b = to180 ( b ) ; return Math . abs ( to180 ( a - b ) ) ; }
Returns the difference between two longitude values . The returned value is always > = 0 .
13,309
public static double to180 ( double d ) { if ( d < 0 ) return - to180 ( abs ( d ) ) ; else { if ( d > 180 ) { long n = round ( floor ( ( d + 180 ) / 360.0 ) ) ; return d - n * 360 ; } else return d ; } }
Converts an angle in degrees to range - 180< x < = 180 .
13,310
public static void runServer ( Module ... modules ) { Injector injector = Guice . createInjector ( modules ) ; PresentsServer server = injector . getInstance ( PresentsServer . class ) ; try { server . init ( injector ) ; String testmod = System . getProperty ( "test_module" ) ; if ( testmod != null ) { try { log . info ( "Invoking test module" , "mod" , testmod ) ; Class < ? > tmclass = Class . forName ( testmod ) ; Runnable trun = ( Runnable ) tmclass . newInstance ( ) ; trun . run ( ) ; } catch ( Exception e ) { log . warning ( "Unable to invoke test module '" + testmod + "'." , e ) ; } } server . run ( ) ; } catch ( Throwable t ) { log . warning ( "Unable to initialize server." , t ) ; System . exit ( - 1 ) ; } }
Inits and runs the PresentsServer bound in the given modules . This blocks until the server is shut down .
13,311
public void run ( ) { ( ( PresentsInvoker ) _invoker ) . postRunnableWhenEmpty ( new Runnable ( ) { public void run ( ) { _omgr . postRunnable ( new LongRunnable ( ) { public void run ( ) { openToThePublic ( ) ; } } ) ; } } ) ; _omgr . run ( ) ; }
Starts up all of the server services and enters the main server event loop .
13,312
protected void openToThePublic ( ) { if ( getListenPorts ( ) . length != 0 && ! _socketAcceptor . bind ( ) ) { queueShutdown ( ) ; } else { _datagramReader . bind ( ) ; _conmgr . start ( ) ; } }
Opens the server for connections after the event thread is running and all the invokers are clear after starting up .
13,313
public void readFrom ( File source ) throws IOException { _lines = Lists . newArrayList ( ) ; BufferedReader bin = new BufferedReader ( new FileReader ( source ) ) ; String line = null ; while ( ( line = bin . readLine ( ) ) != null ) { _lines . add ( line ) ; } bin . close ( ) ; int bstart = - 1 , bend = - 1 ; for ( int ii = 0 , nn = _lines . size ( ) ; ii < nn ; ii ++ ) { line = _lines . get ( ii ) . trim ( ) ; if ( GenUtil . NAME_PATTERN . matcher ( line ) . find ( ) ) { if ( line . endsWith ( "{" ) ) { bstart = ii + 1 ; } else { for ( int oo = 1 ; oo < 10 ; oo ++ ) { if ( safeGetLine ( ii + oo ) . trim ( ) . endsWith ( "{" ) ) { bstart = ii + oo + 1 ; break ; } } } } else if ( line . equals ( "}" ) ) { bend = ii ; } else if ( line . equals ( FIELDS_START ) ) { _nstart = ii ; } else if ( line . equals ( FIELDS_END ) ) { _nend = ii + 1 ; } else if ( line . equals ( METHODS_START ) ) { _mstart = ii ; } else if ( line . equals ( METHODS_END ) ) { _mend = ii + 1 ; } } check ( source , "fields start" , _nstart , "fields end" , _nend ) ; check ( source , "fields end" , _nend , "fields start" , _nstart ) ; check ( source , "methods start" , _mstart , "methods end" , _mend ) ; check ( source , "methods end" , _mend , "methods start" , _mstart ) ; if ( _nstart == - 1 ) { _nstart = bstart ; _nend = bstart ; } if ( _mstart == - 1 ) { _mstart = bend ; _mend = bend ; } }
Reads the code from the supplied source file .
13,314
public boolean containsString ( String text ) { for ( int ii = 0 , nn = _lines . size ( ) ; ii < nn ; ii ++ ) { if ( ! ( ii >= _nstart && ii < _nend ) && ! ( ii >= _mstart && ii < _mend ) && _lines . get ( ii ) . contains ( text ) ) { return true ; } } return false ; }
Returns true if the supplied text appears in the non - auto - generated section .
13,315
public String generate ( String fsection , String msection ) throws IOException { StringWriter writer = new StringWriter ( ) ; BufferedWriter bout = new BufferedWriter ( writer ) ; addOrRemoveGeneratedImport ( StringUtil . deNull ( fsection ) . contains ( "@Generated(" ) || StringUtil . deNull ( msection ) . contains ( "@Generated(" ) ) ; for ( int ii = 0 ; ii < _nstart ; ii ++ ) { writeln ( bout , _lines . get ( ii ) ) ; } if ( ! StringUtil . isBlank ( fsection ) ) { String prev = safeGetLine ( _nstart - 1 ) ; if ( ! StringUtil . isBlank ( prev ) && ! prev . equals ( "{" ) ) { bout . newLine ( ) ; } writeln ( bout , " " + FIELDS_START ) ; bout . write ( fsection ) ; writeln ( bout , " " + FIELDS_END ) ; if ( ! StringUtil . isBlank ( safeGetLine ( _nend ) ) ) { bout . newLine ( ) ; } } for ( int ii = _nend ; ii < _mstart ; ii ++ ) { writeln ( bout , _lines . get ( ii ) ) ; } if ( ! StringUtil . isBlank ( msection ) ) { if ( ! StringUtil . isBlank ( safeGetLine ( _mstart - 1 ) ) ) { bout . newLine ( ) ; } writeln ( bout , " " + METHODS_START ) ; bout . write ( msection ) ; writeln ( bout , " " + METHODS_END ) ; String next = safeGetLine ( _mend ) ; if ( ! StringUtil . isBlank ( next ) && ! next . equals ( "}" ) ) { bout . newLine ( ) ; } } for ( int ii = _mend , nn = _lines . size ( ) ; ii < nn ; ii ++ ) { writeln ( bout , _lines . get ( ii ) ) ; } bout . close ( ) ; return writer . toString ( ) ; }
Writes the code out to the specified file .
13,316
protected void check ( File source , String mname , int mline , String fname , int fline ) throws IOException { if ( mline == - 1 && fline != - 1 ) { throw new IOException ( "Found " + fname + " marker (at line " + ( fline + 1 ) + ") but no " + mname + " marker in '" + source + "'." ) ; } }
Helper function for sanity checking marker existence .
13,317
protected void writeln ( BufferedWriter bout , String line ) throws IOException { bout . write ( line ) ; bout . newLine ( ) ; }
Helper function for writing a string and a newline to a writer .
13,318
protected void addOrRemoveGeneratedImport ( boolean add ) { final String IMPORT = "import javax.annotation.Generated;" ; int packageLine = - 1 ; int importLine = - 1 ; int lastJavaImport = - 1 ; int firstNonJavaImport = - 1 ; for ( int ii = 0 , nn = _lines . size ( ) ; ii < nn ; ii ++ ) { String line = _lines . get ( ii ) ; if ( line . startsWith ( IMPORT ) ) { if ( add ) { return ; } importLine = ii ; break ; } else if ( line . startsWith ( "package " ) ) { packageLine = ii ; } else if ( line . startsWith ( "import java" ) ) { lastJavaImport = ii ; } else if ( firstNonJavaImport == - 1 && line . startsWith ( "import " ) ) { firstNonJavaImport = ii ; } } if ( importLine != - 1 ) { _lines . remove ( importLine ) ; } else if ( ! add ) { return ; } else { importLine = ( lastJavaImport != - 1 ) ? lastJavaImport + 1 : ( ( firstNonJavaImport != - 1 ) ? firstNonJavaImport : packageLine + 1 ) ; _lines . add ( importLine , IMPORT ) ; } int adjustment = add ? 1 : - 1 ; _nstart += adjustment ; _nend += adjustment ; _mstart += adjustment ; _mend += adjustment ; }
Add or remove an import for
13,319
protected void updateBorder ( boolean modified ) { if ( modified ) { setBorder ( BorderFactory . createMatteBorder ( 2 , 2 , 2 , 2 , Color . red ) ) ; } else { setBorder ( BorderFactory . createEmptyBorder ( 2 , 2 , 2 , 2 ) ) ; } }
Sets the appropriate border on this field editor based on whether or not the field is modified .
13,320
public void addListener ( ChangeListener listener , boolean weak ) { int idx = getListenerIndex ( listener ) ; if ( idx == - 1 ) { _listeners = ListUtil . add ( _listeners , weak ? new WeakReference < Object > ( listener ) : listener ) ; return ; } boolean oweak = _listeners [ idx ] instanceof WeakReference < ? > ; if ( weak == oweak ) { log . warning ( "Refusing repeat listener registration" , "dobj" , which ( ) , "list" , listener , new Exception ( ) ) ; } else { log . warning ( "Updating listener registered under different strength." , "dobj" , which ( ) , "list" , listener , "oweak" , oweak , "nweak" , weak , new Exception ( ) ) ; _listeners [ idx ] = weak ? new WeakReference < Object > ( listener ) : listener ; } }
Adds an event listener to this object . The listener will be notified when any events are dispatched on this object that match their particular listener interface .
13,321
public void removeListener ( ChangeListener listener ) { int idx = getListenerIndex ( listener ) ; if ( idx != - 1 ) { _listeners [ idx ] = null ; } }
Removes an event listener from this object . The listener will no longer be notified when events are dispatched on this object .
13,322
public final < T extends DSet . Entry > DSet < T > getSet ( String setName ) { @ SuppressWarnings ( "unchecked" ) DSet < T > casted = ( DSet < T > ) getAccessor ( setName ) . get ( this ) ; return casted ; }
Get the DSet with the specified name .
13,323
public < T extends DSet . Entry > void addToSet ( String setName , T entry ) { requestEntryAdd ( setName , getSet ( setName ) , entry ) ; }
Request to have the specified item added to the specified DSet .
13,324
public void updateSet ( String setName , DSet . Entry entry ) { requestEntryUpdate ( setName , getSet ( setName ) , entry ) ; }
Request to have the specified item updated in the specified DSet .
13,325
public void removeFromSet ( String setName , Comparable < ? > key ) { requestEntryRemove ( setName , getSet ( setName ) , key ) ; }
Request to have the specified key removed from the specified DSet .
13,326
public void notifyListeners ( DEvent event ) { if ( _listeners == null ) { return ; } for ( int ii = 0 , ll = _listeners . length ; ii < ll ; ii ++ ) { Object listener = _listeners [ ii ] ; if ( listener == null ) { continue ; } if ( listener instanceof WeakReference < ? > ) { if ( ( listener = ( ( WeakReference < ? > ) listener ) . get ( ) ) == null ) { _listeners [ ii ] = null ; continue ; } } try { event . notifyListener ( listener ) ; if ( listener instanceof EventListener ) { ( ( EventListener ) listener ) . eventReceived ( event ) ; } } catch ( Exception e ) { log . warning ( "Listener choked during notification" , "list" , listener , "event" , event , e ) ; } } }
Called by the distributed object manager after it has applied an event to this object . This dispatches an event notification to all of the listeners registered with this object .
13,327
public void notifyProxies ( DEvent event ) { if ( _subs == null || event . isPrivate ( ) ) { return ; } for ( Object sub : _subs ) { try { if ( sub != null && sub instanceof ProxySubscriber ) { ( ( ProxySubscriber ) sub ) . eventReceived ( event ) ; } } catch ( Exception e ) { log . warning ( "Proxy choked during notification" , "sub" , sub , "event" , event , e ) ; } } }
Called by the distributed object manager after it has applied an event to this object . This dispatches an event notification to all of the proxy listeners registered with this object .
13,328
public void changeAttribute ( String name , Object value ) { Accessor acc = getAccessor ( name ) ; requestAttributeChange ( name , value , acc . get ( this ) ) ; acc . set ( this , value ) ; }
Requests that the specified attribute be changed to the specified value . Normally the generated setter methods should be used but in rare cases a caller may wish to update distributed fields in a generic manner .
13,329
public void postEvent ( DEvent event ) { if ( _tevent != null ) { _tevent . postEvent ( event ) ; } else if ( _omgr != null ) { _omgr . postEvent ( event ) ; } else { log . info ( "Dropping event for non- or no longer managed object" , "oid" , getOid ( ) , "class" , getClass ( ) . getName ( ) , "event" , event ) ; } }
Posts the specified event either to our dobject manager or to the compound event for which we are currently transacting .
13,330
protected void which ( StringBuilder buf ) { buf . append ( StringUtil . shortClassName ( this ) ) ; buf . append ( ":" ) . append ( _oid ) ; }
Used to briefly describe this distributed object .
13,331
public void commitTransaction ( ) { if ( _tevent == null ) { String errmsg = "Cannot commit: not involved in a transaction [dobj=" + this + "]" ; throw new IllegalStateException ( errmsg ) ; } if ( _tcount > 0 ) { _tcount -- ; } else { if ( _tcancelled ) { _tevent . cancel ( ) ; } else { _tevent . commit ( ) ; } } }
Commits the transaction in which this distributed object is involved .
13,332
public void cancelTransaction ( ) { if ( _tevent == null ) { String errmsg = "Cannot cancel: not involved in a transaction [dobj=" + this + "]" ; throw new IllegalStateException ( errmsg ) ; } if ( _tcount > 0 ) { _tcancelled = true ; _tcount -- ; } else { _tevent . cancel ( ) ; } }
Cancels the transaction in which this distributed object is involved .
13,333
protected void requestOidAdd ( String name , OidList list , int oid ) { boolean applyImmediately = isAuthoritative ( ) ; if ( applyImmediately ) { list . add ( oid ) ; } postEvent ( new ObjectAddedEvent ( _oid , name , oid ) . setAlreadyApplied ( applyImmediately ) ) ; }
Calls by derived instances when an oid adder method was called .
13,334
protected void requestOidRemove ( String name , OidList list , int oid ) { boolean applyImmediately = isAuthoritative ( ) ; if ( applyImmediately ) { list . remove ( oid ) ; } postEvent ( new ObjectRemovedEvent ( _oid , name , oid ) . setAlreadyApplied ( applyImmediately ) ) ; }
Calls by derived instances when an oid remover method was called .
13,335
protected < T extends DSet . Entry > void requestEntryAdd ( String name , DSet < T > set , T entry ) { boolean applyImmediately = isAuthoritative ( ) ; if ( applyImmediately ) { set . add ( entry ) ; } postEvent ( new EntryAddedEvent < T > ( _oid , name , entry ) . setAlreadyApplied ( applyImmediately ) ) ; }
Calls by derived instances when a set adder method was called .
13,336
protected < T extends DSet . Entry > void requestEntryRemove ( String name , DSet < T > set , Comparable < ? > key ) { T oldEntry = null ; if ( isAuthoritative ( ) ) { oldEntry = set . removeKey ( key ) ; if ( oldEntry == null ) { log . warning ( "Requested to remove non-element" , "set" , name , "key" , key , new Exception ( ) ) ; } } postEvent ( new EntryRemovedEvent < T > ( _oid , name , key ) . setOldEntry ( oldEntry ) ) ; }
Calls by derived instances when a set remover method was called .
13,337
protected Accessor [ ] createAccessors ( ) { Field [ ] fields = getClass ( ) . getFields ( ) ; List < Accessor > accs = Lists . newArrayListWithExpectedSize ( fields . length / 2 ) ; for ( Field field : fields ) { if ( ! Modifier . isStatic ( field . getModifiers ( ) ) ) { accs . add ( new Accessor . ByField ( field ) ) ; } } return accs . toArray ( new Accessor [ accs . size ( ) ] ) ; }
Creates the accessors that will be used to read and write this object s attributes . The default implementation assumes the object s attributes are all public fields and uses reflection to get and set their values .
13,338
protected int getListenerIndex ( ChangeListener listener ) { if ( _listeners == null ) { return - 1 ; } for ( int ii = 0 , ll = _listeners . length ; ii < ll ; ii ++ ) { Object olistener = _listeners [ ii ] ; if ( olistener == listener || ( olistener instanceof WeakReference < ? > && ( ( WeakReference < ? > ) olistener ) . get ( ) == listener ) ) { return ii ; } } return - 1 ; }
Returns the index of the identified listener or - 1 if not found .
13,339
public void getConfigInfo ( ClientObject caller , AdminService . ConfigInfoListener listener ) throws InvocationException { String [ ] keys = _registry . getKeys ( ) ; int [ ] oids = new int [ keys . length ] ; for ( int ii = 0 ; ii < keys . length ; ii ++ ) { oids [ ii ] = _registry . getObject ( keys [ ii ] ) . getOid ( ) ; } listener . gotConfigInfo ( keys , oids ) ; }
from interface AdminProvider
13,340
protected static String createAuthToken ( String clientId , String sharedSecret ) { return StringUtil . md5hex ( clientId + sharedSecret ) ; }
Creates a unique password for the specified node using the supplied shared secret .
13,341
public boolean bind ( ) { int successes = 0 ; for ( int port : _ports ) { try { acceptConnections ( port ) ; successes ++ ; } catch ( IOException ioe ) { log . warning ( "Failure listening to socket" , "hostname" , _bindHostname , "port" , port , ioe ) ; } } return successes > 0 ; }
Bind to the socket ports and return true if any of the binds succeeded .
13,342
public void shutdown ( ) { for ( ServerSocketChannel ssocket : _ssockets ) { try { ssocket . socket ( ) . close ( ) ; } catch ( IOException ioe ) { log . warning ( "Failed to close listening socket: " + ssocket , ioe ) ; } } }
Unbind our listening sockets .
13,343
public ServiceMethod createAndGatherImports ( Method method , ImportSet imports ) { ServiceMethod sm = new ServiceMethod ( method ) ; sm . gatherImports ( imports ) ; return sm ; }
Creates a new service method and adds its basic imports to a set .
13,344
protected long getDelta ( long timeStamp , long maxValue ) { boolean even = ( evenBase > oddBase ) ; long base = even ? evenBase : oddBase ; long delta = timeStamp - base ; if ( delta < 0 ) { String errmsg = "Time stamp too old for conversion to delta time" ; throw new IllegalArgumentException ( errmsg ) ; } if ( delta > maxValue ) { if ( even ) { setOddBase ( timeStamp ) ; } else { setEvenBase ( timeStamp ) ; } delta = 0 ; } if ( ! even ) { delta = ( - 1 - delta ) ; } return delta ; }
Obtains a delta with the specified maximum value swapping from even to odd if necessary .
13,345
public String checkAccess ( Permission perm , Object context ) { if ( _permPolicy == null ) { _permPolicy = createPermissionPolicy ( ) ; } return _permPolicy . checkAccess ( perm , context ) ; }
Checks whether or not this client has the specified permission .
13,346
public MarcValueTransformers setMarcValueTransformer ( String fieldKey , MarcValueTransformer transformer ) { int pos = fieldKey . lastIndexOf ( '$' ) ; String tagind = pos > 0 ? fieldKey . substring ( 0 , pos ) : fieldKey ; String subs = pos > 0 ? fieldKey . substring ( pos + 1 ) : "" ; this . marcValueTransformerMap . put ( tagind , transformer ) ; this . subfieldMap . put ( tagind , subs ) ; return this ; }
Set MARC value transformer for transforming field values .
13,347
public MarcField transformValue ( MarcField field ) { String key = field . toTagIndicatorKey ( ) ; if ( marcValueTransformerMap . isEmpty ( ) ) { return field ; } final MarcValueTransformer transformer = marcValueTransformerMap . containsKey ( key ) ? marcValueTransformerMap . get ( key ) : marcValueTransformerMap . get ( DEFAULT ) ; if ( transformer != null ) { MarcField . Builder builder = MarcField . builder ( ) ; builder . tag ( field . getTag ( ) ) . indicator ( field . getIndicator ( ) ) ; if ( field . getValue ( ) != null ) { builder . value ( transformer . transform ( field . getValue ( ) ) ) ; } String subs = subfieldMap . containsKey ( key ) ? subfieldMap . get ( key ) : field . getSubfieldIds ( ) ; field . getSubfields ( ) . forEach ( subfield -> builder . subfield ( subfield . getId ( ) , subs . contains ( subfield . getId ( ) ) ? transformer . transform ( subfield . getValue ( ) ) : subfield . getValue ( ) ) ) ; return builder . build ( ) ; } return field ; }
Transform value .
13,348
protected final void expand ( int needed ) { int ocapacity = _buffer . capacity ( ) ; int ncapacity = _buffer . position ( ) + needed ; if ( ncapacity > ocapacity ) { ncapacity = Math . max ( ocapacity << 1 , ncapacity ) ; ByteBuffer newbuf = ByteBuffer . allocate ( ncapacity ) ; newbuf . put ( ( ByteBuffer ) _buffer . flip ( ) ) ; _buffer = newbuf ; } }
Expands our buffer to accomodate the specified capacity .
13,349
public static UserSystemMessage create ( Name sender , String message , String bundle ) { return new UserSystemMessage ( sender , message , bundle , INFO ) ; }
Construct a INFO - level UserSystemMessage .
13,350
public void setLine ( int ... points ) { double [ ] pd = new double [ points . length ] ; for ( int i = 0 ; i < points . length ; i ++ ) { pd [ i ] = points [ i ] ; } setLine ( pd ) ; }
Sets the curve using control points given in integer precision
13,351
public void setLine ( Point2D [ ] points ) { double [ ] pd = new double [ points . length * 2 ] ; for ( int i = 0 ; i < points . length ; i ++ ) { Point2D p = points [ i ] ; pd [ i * 2 ] = p . getX ( ) ; pd [ i * 2 + 1 ] = p . getY ( ) ; } setLine ( pd ) ; }
Sets the curve using control points given as Point2D objects
13,352
public void addClientObserver ( ClientObserver observer ) { _clobservers . add ( observer ) ; if ( observer instanceof DetailedClientObserver ) { _dclobservers . add ( ( DetailedClientObserver ) observer ) ; } }
Registers an observer that will be notified when clients start and end their sessions .
13,353
public void applyToClient ( Name username , final ClientOp clop ) { resolveClientObject ( username , new ClientResolutionListener ( ) { public void clientResolved ( Name username , ClientObject clobj ) { try { clop . apply ( clobj ) ; } catch ( Exception e ) { log . warning ( "Client op failed" , "username" , username , "clop" , clop , e ) ; } finally { releaseClientObject ( username ) ; } } public void resolutionFailed ( Name username , Exception reason ) { clop . resolutionFailed ( reason ) ; } } ) ; }
Resolves the specified client applies the supplied client operation to them and releases the client .
13,354
public void shutdown ( ) { log . info ( "Client manager shutting down" , "ccount" , _usermap . size ( ) ) ; synchronized ( _usermap ) { for ( PresentsSession pc : _usermap . values ( ) ) { try { pc . shutdown ( ) ; } catch ( Exception e ) { log . warning ( "Client choked in shutdown()" , "client" , StringUtil . safeToString ( pc ) , e ) ; } } } }
from interface Lifecycle . Component
13,355
public synchronized void clientResolved ( Name username , ClientObject clobj ) { clobj . release ( ) ; _objmap . put ( username , clobj ) ; _penders . remove ( username ) ; }
documentation inherited from interface ClientResolutionListener
13,356
public synchronized void connectionEstablished ( PresentsConnection conn , Name authname , AuthRequest req , AuthResponse rsp ) { String type = authname . getClass ( ) . getSimpleName ( ) ; PresentsSession session = getClient ( authname ) ; if ( session != null ) { session . resumeSession ( req , conn ) ; } else { log . info ( "Session initiated" , "type" , type , "who" , authname , "conn" , conn ) ; Class < ? extends PresentsSession > sessionClass = null ; for ( SessionFactory factory : _factories ) { if ( ( sessionClass = factory . getSessionClass ( req ) ) != null ) { break ; } } session = _injector . getInstance ( sessionClass ) ; session . startSession ( authname , req , conn , rsp . authdata ) ; synchronized ( _usermap ) { _usermap . put ( session . getAuthName ( ) , session ) ; } } _conmap . put ( conn , session ) ; }
Called by the connection manager to let us know when a new connection has been established .
13,357
public synchronized void connectionFailed ( Connection conn , IOException fault ) { PresentsSession session = _conmap . remove ( conn ) ; if ( session != null ) { log . info ( "Unmapped failed session" , "session" , session , "conn" , conn , "fault" , fault ) ; session . wasUnmapped ( ) ; session . connectionFailed ( fault ) ; } else if ( ! ( conn instanceof AuthingConnection ) ) { log . info ( "Unmapped connection failed?" , "conn" , conn , "fault" , fault , new Exception ( ) ) ; } }
Called by the connection manager to let us know when a connection has failed .
13,358
public synchronized void connectionClosed ( Connection conn ) { PresentsSession session = _conmap . remove ( conn ) ; if ( session != null ) { log . debug ( "Unmapped session" , "session" , session , "conn" , conn ) ; session . wasUnmapped ( ) ; } else { log . debug ( "Closed unmapped connection '" + conn + "'. " + "Session probably not yet authenticated." ) ; } }
Called by the connection manager to let us know when a connection has been closed .
13,359
public void appendReport ( StringBuilder report , long now , long sinceLast , boolean reset ) { report . append ( "* presents.ClientManager:\n" ) ; report . append ( "- Sessions: " ) ; synchronized ( _usermap ) { report . append ( _usermap . size ( ) ) . append ( " total, " ) ; } report . append ( _conmap . size ( ) ) . append ( " connected, " ) ; report . append ( _penders . size ( ) ) . append ( " pending\n" ) ; report . append ( "- Mapped users: " ) . append ( _objmap . size ( ) ) . append ( "\n" ) ; }
documentation inherited from interface ReportManager . Reporter
13,360
protected void clientSessionWillEnd ( final PresentsSession session ) { _dclobservers . apply ( new ObserverList . ObserverOp < DetailedClientObserver > ( ) { public boolean apply ( DetailedClientObserver observer ) { observer . clientSessionWillEnd ( session ) ; return true ; } } ) ; }
Called by PresentsSession when it is about to end its session .
13,361
protected void clientSessionDidEnd ( final PresentsSession session ) { _clobservers . apply ( new ObserverList . ObserverOp < ClientObserver > ( ) { public boolean apply ( ClientObserver observer ) { observer . clientSessionDidEnd ( session ) ; return true ; } } ) ; }
Called by PresentsSession when it has ended its session .
13,362
protected void clearSession ( PresentsSession session ) { PresentsSession rc ; synchronized ( _usermap ) { rc = _usermap . remove ( session . getAuthName ( ) ) ; } if ( rc == null ) { log . info ( "Cleared session: unregistered!" , "session" , session ) ; } else if ( rc != session ) { log . info ( "Cleared session: multiple!" , "s1" , rc , "s2" , session ) ; } else { log . info ( "Cleared session" , "session" , session ) ; } }
Called by PresentsSession to let us know that we can clear it entirely out of the system .
13,363
protected void flushSessions ( ) { List < PresentsSession > victims = Lists . newArrayList ( ) ; long now = System . currentTimeMillis ( ) ; synchronized ( _usermap ) { for ( PresentsSession session : _usermap . values ( ) ) { if ( session . checkExpired ( now ) ) { victims . add ( session ) ; } } } for ( PresentsSession session : victims ) { try { log . info ( "Session expired, ending session" , "session" , session , "dtime" , ( now - session . getNetworkStamp ( ) ) + "ms]." ) ; session . endSession ( ) ; } catch ( Exception e ) { log . warning ( "Choke while flushing session" , "victim" , session , e ) ; } } }
Called once per minute to check for sessions that have been disconnected too long and forcibly end their sessions .
13,364
protected String getLabel ( ArgumentComponent argumentComponent , Token token ) { StringBuilder sb = new StringBuilder ( argumentComponent . getClass ( ) . getSimpleName ( ) ) ; if ( "BIO" . equals ( this . codingGranularity ) ) { if ( argumentComponent . getBegin ( ) == token . getBegin ( ) ) { sb . append ( B_SUFFIX ) ; } else { sb . append ( I_SUFFIX ) ; } } else { sb . append ( I_SUFFIX ) ; } return sb . toString ( ) ; }
Returns a label for the annotated token
13,365
protected synchronized boolean clearPPI ( boolean cancel ) { if ( _prefPortInterval != null ) { if ( cancel ) { _prefPortInterval . cancel ( ) ; _prefPortInterval . failed ( ) ; } _prefPortInterval = null ; return true ; } return false ; }
Cancels our preferred port saving interval . This method is called from the communication reader thread and the interval thread and must thus be synchronized .
13,366
public CacheManagerPeerProvider createCachePeerProvider ( CacheManager cacheManager , Properties properties ) { if ( _instance == null ) { _instance = new Provider ( cacheManager ) ; } return _instance ; }
Return our provider creating it if needed .
13,367
public Stream < Chunk < byte [ ] , BytesReference > > chunks ( ) { Iterator < Chunk < byte [ ] , BytesReference > > iterator = new Iterator < Chunk < byte [ ] , BytesReference > > ( ) { Chunk < byte [ ] , BytesReference > nextData = null ; public boolean hasNext ( ) { if ( nextData != null ) { return true ; } else { try { nextData = readChunk ( ) ; return nextData != null ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public Chunk < byte [ ] , BytesReference > next ( ) { if ( nextData != null || hasNext ( ) ) { Chunk < byte [ ] , BytesReference > data = nextData ; nextData = null ; return data ; } else { throw new NoSuchElementException ( ) ; } } } ; return StreamSupport . stream ( Spliterators . spliteratorUnknownSize ( iterator , Spliterator . ORDERED | Spliterator . NONNULL ) , false ) ; }
This methods creates a Java 8 stream of chunks .
13,368
public void decrypt ( byte [ ] key ) throws IOException , ClassNotFoundException { if ( _clearCreds != null ) { return ; } _key = key ; try { _contents = SecureUtil . getAESCipher ( Cipher . DECRYPT_MODE , _key ) . doFinal ( _contents ) ; } catch ( GeneralSecurityException gse ) { IOException ioe = new IOException ( "Failed to decrypt credentials" ) ; ioe . initCause ( gse ) ; throw ioe ; } ByteArrayInputStream byteIn = new ByteArrayInputStream ( _contents ) ; ObjectInputStream cipherIn = new ObjectInputStream ( byteIn ) ; _clearCreds = ( Credentials ) cipherIn . readObject ( ) ; }
Decrypts the request after transmission .
13,369
public void writeObject ( ObjectOutputStream out ) throws IOException { out . defaultWriteObject ( ) ; ByteArrayOutputStream byteOut = new ByteArrayOutputStream ( ) ; ObjectOutputStream oOut = new ObjectOutputStream ( byteOut ) ; oOut . writeObject ( _clearCreds ) ; try { byte [ ] encrypted = SecureUtil . getAESCipher ( Cipher . ENCRYPT_MODE , _key ) . doFinal ( byteOut . toByteArray ( ) ) ; out . writeInt ( encrypted . length ) ; out . write ( encrypted ) ; } catch ( GeneralSecurityException gse ) { IOException ioe = new IOException ( "Failed to encrypt credentials" ) ; ioe . initCause ( gse ) ; throw ioe ; } }
A customized AES encrypting write object .
13,370
public void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; _contents = new byte [ in . readInt ( ) ] ; in . read ( _contents ) ; }
Read in our encrypted contents .
13,371
protected synchronized void connectionFailed ( final IOException ioe ) { if ( _channel == null ) { return ; } log . info ( "Connection failed" , ioe ) ; notifyClientObservers ( new ObserverOps . Client ( _client ) { protected void notify ( ClientObserver obs ) { obs . clientConnectionFailed ( _client , ioe ) ; } } ) ; logoff ( ) ; }
Callback called by the reader or writer thread when something goes awry with our socket connection to the server .
13,372
protected synchronized void readerDidExit ( ) { _reader = null ; if ( _writer == null ) { closeChannel ( ) ; clientCleanup ( _logonError ) ; } log . debug ( "Reader thread exited." ) ; }
Callback called by the reader thread when it goes away .
13,373
protected synchronized void writerDidExit ( ) { _writer = null ; log . debug ( "Writer thread exited." ) ; notifyClientObservers ( new ObserverOps . Session ( _client ) { protected void notify ( SessionObserver obs ) { obs . clientDidLogoff ( _client ) ; } } ) ; closeChannel ( ) ; if ( _reader == null ) { clientCleanup ( _logonError ) ; } }
Callback called by the writer thread when it goes away .
13,374
protected void closeDatagramChannel ( ) { if ( _selector != null ) { try { _selector . close ( ) ; } catch ( IOException ioe ) { log . warning ( "Error closing selector: " + ioe ) ; } _selector = null ; } if ( _datagramChannel != null ) { log . debug ( "Closing datagram socket channel." ) ; try { _datagramChannel . close ( ) ; } catch ( IOException ioe ) { log . warning ( "Error closing datagram socket: " + ioe ) ; } _datagramChannel = null ; _uout = null ; _sequencer = null ; } }
Closes the datagram channel .
13,375
protected void sendMessage ( UpstreamMessage msg ) throws IOException { if ( debugLogMessages ( ) ) { log . info ( "SEND " + msg ) ; } _oout . writeObject ( msg ) ; _oout . flush ( ) ; try { ByteBuffer buffer = _fout . frameAndReturnBuffer ( ) ; if ( buffer . limit ( ) > 4096 ) { String txt = StringUtil . truncate ( String . valueOf ( msg ) , 80 , "..." ) ; log . info ( "Whoa, writin' a big one" , "msg" , txt , "size" , buffer . limit ( ) ) ; } int wrote = writeMessage ( buffer ) ; if ( wrote != buffer . limit ( ) ) { log . warning ( "Aiya! Couldn't write entire message" , "msg" , msg , "size" , buffer . limit ( ) , "wrote" , wrote ) ; } else { _client . getMessageTracker ( ) . messageSent ( false , wrote , msg ) ; } } finally { _fout . resetFrame ( ) ; } updateWriteStamp ( ) ; }
Writes the supplied message to the socket .
13,376
protected void sendDatagram ( UpstreamMessage msg ) throws IOException { _bout . reset ( ) ; _uout . writeInt ( _client . getConnectionId ( ) ) ; _uout . writeLong ( 0L ) ; _sequencer . writeDatagram ( msg ) ; ByteBuffer buf = _bout . flip ( ) ; int size = buf . remaining ( ) ; if ( size > Client . MAX_DATAGRAM_SIZE ) { log . warning ( "Dropping oversized datagram" , "size" , size , "msg" , msg ) ; return ; } buf . position ( 12 ) ; _digest . update ( buf ) ; byte [ ] hash = _digest . digest ( _secret ) ; buf . position ( 4 ) ; buf . put ( hash , 0 , 8 ) . rewind ( ) ; writeDatagram ( buf ) ; _client . getMessageTracker ( ) . messageSent ( true , size , msg ) ; }
Sends a datagram over the datagram socket .
13,377
protected void throttleOutgoingMessage ( ) { Throttle throttle = _client . getOutgoingMessageThrottle ( ) ; synchronized ( throttle ) { while ( throttle . throttleOp ( ) ) { try { Thread . sleep ( 2 ) ; } catch ( InterruptedException ie ) { } } } }
Throttles an outgoing message operation in a thread - safe manner .
13,378
private String interpolate ( MarcField marcField , String value ) { if ( value == null ) { return null ; } Matcher m = REP . matcher ( value ) ; if ( m . find ( ) ) { return m . replaceAll ( Integer . toString ( repeatCounter ) ) ; } m = NREP . matcher ( value ) ; if ( m . find ( ) ) { if ( repeatCounter > 99 ) { repeatCounter = 99 ; logger . log ( Level . WARNING , "counter > 99, overflow in %s" , marcField ) ; } return m . replaceAll ( String . format ( "%02d" , repeatCounter ) ) ; } return value ; }
Interpolate variables .
13,379
public PlaceController createController ( ) { Class < ? > cclass = getControllerClass ( ) ; if ( cclass == null ) { throw new RuntimeException ( "PlaceConfig.createController() must be overridden." ) ; } log . warning ( "Providing backwards compatibility. PlaceConfig." + "createController() should be overridden directly." ) ; try { return ( PlaceController ) cclass . newInstance ( ) ; } catch ( Exception e ) { log . warning ( "Failed to instantiate controller class '" + cclass + "'." , e ) ; return null ; } }
Create the controller that should be used for this place .
13,380
protected void addWhoData ( StringBuilder buf ) { buf . append ( getOid ( ) ) ; if ( status != OccupantInfo . ACTIVE ) { buf . append ( " " ) . append ( getStatusTranslation ( ) ) ; } }
Allows derived classes to add data to the who details .
13,381
public static void init ( InvocationManager invmgr , RootDObjectManager omgr ) { _invmgr = invmgr ; _omgr = omgr ; invmgr . registerProvider ( new TimeBaseProvider ( ) , TimeBaseMarshaller . class , GLOBAL_GROUP ) ; }
Registers the time provider with the appropriate managers . Called by the presents server at startup .
13,382
public static TimeBaseObject createTimeBase ( String timeBase ) { TimeBaseObject object = _omgr . registerObject ( new TimeBaseObject ( ) ) ; _timeBases . put ( timeBase , object ) ; return object ; }
Creates a time base object which can subsequently be fetched by the client and used to send delta times .
13,383
public void getTimeOid ( ClientObject source , String timeBase , TimeBaseService . GotTimeBaseListener listener ) throws InvocationException { TimeBaseObject time = getTimeBase ( timeBase ) ; if ( time == null ) { throw new InvocationException ( NO_SUCH_TIME_BASE ) ; } listener . gotTimeOid ( time . getOid ( ) ) ; }
Processes a request from a client to fetch the oid of the specified time object .
13,384
public Iterable < NodeObject > getNodeObjects ( ) { return Iterables . filter ( Iterables . concat ( Collections . singleton ( _nodeobj ) , Iterables . transform ( _peers . values ( ) , GET_NODE_OBJECT ) ) , Predicates . notNull ( ) ) ; }
Returns an iterable over our node object and that of our peers .
13,385
public ClientInfo locateClient ( final Name key ) { return lookupNodeDatum ( new Function < NodeObject , ClientInfo > ( ) { public ClientInfo apply ( NodeObject nodeobj ) { return nodeobj . clients . get ( key ) ; } } ) ; }
Locates the client with the specified name . Returns null if the client is not logged onto any peer .
13,386
public void invokeNodeAction ( final NodeAction action , final Runnable onDropped ) { if ( ! _omgr . isDispatchThread ( ) ) { _omgr . postRunnable ( new Runnable ( ) { public void run ( ) { invokeNodeAction ( action , onDropped ) ; } } ) ; return ; } byte [ ] actionBytes = flattenAction ( action ) ; boolean invoked = false ; if ( action . isApplicable ( _nodeobj ) ) { invokeAction ( null , actionBytes ) ; invoked = true ; } for ( PeerNode peer : _peers . values ( ) ) { if ( peer . nodeobj != null && action . isApplicable ( peer . nodeobj ) ) { peer . nodeobj . peerService . invokeAction ( actionBytes ) ; invoked = true ; } } if ( ! invoked && onDropped != null ) { onDropped . run ( ) ; } if ( invoked ) { _stats . noteNodeActionInvoked ( action ) ; } }
Invokes the supplied action on this and any other server that it indicates is appropriate . The action will be executed on the distributed object thread but this method does not need to be called from the distributed object thread .
13,387
public < T > void invokeNodeRequest ( final NodeRequest request , final NodeRequestsListener < T > listener ) { if ( ! _omgr . isDispatchThread ( ) ) { _omgr . postRunnable ( new Runnable ( ) { public void run ( ) { invokeNodeRequest ( request , listener ) ; } } ) ; return ; } byte [ ] requestBytes = flattenRequest ( request ) ; final Set < String > nodes = findApplicableNodes ( request ) ; if ( nodes . isEmpty ( ) ) { listener . requestsProcessed ( new NodeRequestsResultImpl < T > ( ) ) ; return ; } final Map < String , T > results = Maps . newHashMap ( ) ; final Map < String , String > failures = Maps . newHashMap ( ) ; final AtomicInteger completedNodes = new AtomicInteger ( ) ; for ( final String node : nodes ) { invokeNodeRequest ( node , requestBytes , new InvocationService . ResultListener ( ) { public void requestProcessed ( Object result ) { @ SuppressWarnings ( "unchecked" ) T castResult = ( T ) result ; results . put ( node , castResult ) ; nodeDone ( ) ; } public void requestFailed ( String cause ) { failures . put ( node , cause ) ; nodeDone ( ) ; } protected void nodeDone ( ) { if ( completedNodes . incrementAndGet ( ) == nodes . size ( ) ) { listener . requestsProcessed ( new NodeRequestsResultImpl < T > ( results , failures ) ) ; } } } ) ; } }
Invokes the supplied request on all servers in parallel . The request will execute on the distributed object thread but this method does not need to be called from there .
13,388
public void invokeNodeRequest ( String nodeName , NodeRequest request , InvocationService . ResultListener listener ) { invokeNodeRequest ( nodeName , flattenRequest ( request ) , listener ) ; }
Invokes a node request on a specific node and returns the result through the listener .
13,389
public < T extends DObject > void proxyRemoteObject ( String nodeName , final int remoteOid , final ResultListener < Integer > listener ) { proxyRemoteObject ( new DObjectAddress ( nodeName , remoteOid ) , listener ) ; }
Initiates a proxy on an object that is managed by the specified peer . The object will be proxied into this server s distributed object space and its local oid reported back to the supplied result listener .
13,390
public void unproxyRemoteObject ( DObjectAddress addr ) { Tuple < Subscriber < ? > , DObject > bits = _proxies . remove ( addr ) ; if ( bits == null ) { log . warning ( "Requested to clear unknown proxy" , "addr" , addr ) ; return ; } if ( Objects . equal ( addr . nodeName , _nodeName ) ) { bits . right . removeSubscriber ( bits . left ) ; return ; } _omgr . clearProxyObject ( addr . oid , bits . right ) ; final Client peer = getPeerClient ( addr . nodeName ) ; if ( peer == null ) { log . warning ( "Unable to unsubscribe from proxy, missing peer" , "addr" , addr ) ; return ; } bits . right . setOid ( addr . oid ) ; bits . right . setManager ( peer . getDObjectManager ( ) ) ; peer . getDObjectManager ( ) . unsubscribeFromObject ( addr . oid , bits . left ) ; }
Unsubscribes from and clears a proxied object . The caller must be sure that there are no remaining subscribers to the object on this local server .
13,391
public String getPeerPublicHostName ( String nodeName ) { if ( Objects . equal ( _nodeName , nodeName ) ) { return _self . publicHostName ; } PeerNode peer = _peers . get ( nodeName ) ; return ( peer == null ) ? null : peer . getPublicHostName ( ) ; }
Returns the public hostname to use when connecting to the specified peer or null if the peer is not currently connected to this server .
13,392
public String getPeerInternalHostName ( String nodeName ) { if ( Objects . equal ( _nodeName , nodeName ) ) { return _self . hostName ; } PeerNode peer = _peers . get ( nodeName ) ; return ( peer == null ) ? null : peer . getInternalHostName ( ) ; }
Returns the internal hostname to use when connecting to the specified peer or null if the peer is not currently connected to this server . Peers connect to one another via their internal hostname . Do not publish this data to clients out on the Internets .
13,393
public int getPeerPort ( String nodeName ) { if ( Objects . equal ( _nodeName , nodeName ) ) { return _self . port ; } PeerNode peer = _peers . get ( nodeName ) ; return ( peer == null ) ? - 1 : peer . getPort ( ) ; }
Returns the port on which to connect to the specified peer or - 1 if the peer is not currently connected to this server .
13,394
public void acquireLock ( final NodeObject . Lock lock , final ResultListener < String > listener ) { queryLock ( lock , new ChainedResultListener < String , String > ( listener ) { public void requestCompleted ( String result ) { if ( result == null ) { if ( _suboids . isEmpty ( ) ) { lockAcquired ( lock , 0L , listener ) ; } else { _locks . put ( lock , new LockHandler ( lock , true , listener ) ) ; } } else { listener . requestCompleted ( result ) ; } } } ) ; }
Acquires a lock on a resource shared amongst this node s peers . If the lock is successfully acquired the supplied listener will receive this node s name . If another node acquires the lock first then the listener will receive the name of that node .
13,395
public void queryLock ( NodeObject . Lock lock , ResultListener < String > listener ) { LockHandler handler = _locks . get ( lock ) ; if ( handler != null ) { handler . listeners . add ( listener ) ; return ; } listener . requestCompleted ( queryLock ( lock ) ) ; }
Determines the owner of the specified lock waiting for any resolution to complete before notifying the supplied listener .
13,396
public void addStaleCacheObserver ( String cache , StaleCacheObserver observer ) { ObserverList < StaleCacheObserver > list = _cacheobs . get ( cache ) ; if ( list == null ) { list = ObserverList . newFastUnsafe ( ) ; _cacheobs . put ( cache , list ) ; } list . add ( observer ) ; }
Registers a stale cache observer .
13,397
public void removeStaleCacheObserver ( String cache , StaleCacheObserver observer ) { ObserverList < StaleCacheObserver > list = _cacheobs . get ( cache ) ; if ( list == null ) { return ; } list . remove ( observer ) ; if ( list . isEmpty ( ) ) { _cacheobs . remove ( cache ) ; } }
Removes a stale cache observer registration .
13,398
public void broadcastStaleCacheData ( String cache , Streamable data ) { _nodeobj . setCacheData ( new NodeObject . CacheData ( cache , data ) ) ; }
Called when cached data has changed on the local server and needs to inform our peers .
13,399
protected void refreshPeer ( NodeRecord record ) { PeerNode peer = _peers . get ( record . nodeName ) ; if ( peer == null ) { peer = _injector . getInstance ( getPeerNodeClass ( ) ) ; _peers . put ( record . nodeName , peer ) ; peer . init ( record ) ; } peer . refresh ( record ) ; }
Ensures that we have a connection to the specified node if it has checked in since we last failed to connect .