idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
13,600 | public Transport combine ( Transport other ) { return getInstance ( _type . combine ( other . _type ) , ( _channel == other . _channel ) ? _channel : 0 ) ; } | Returns a transport that satisfies the requirements of this and the specified other transport . |
13,601 | public void broadcast ( Name from , String bundle , String msg , boolean attention , boolean forward ) { byte levelOrMode = ( from != null ) ? ChatCodes . BROADCAST_MODE : ( attention ? SystemMessage . ATTENTION : SystemMessage . INFO ) ; broadcast ( from , levelOrMode , bundle , msg , forward ) ; } | Broadcasts the specified message to all place objects in the system . |
13,602 | public void broadcast ( Name from , byte levelOrMode , String bundle , String msg , boolean forward ) { if ( _broadcastObject != null ) { broadcastTo ( _broadcastObject , from , levelOrMode , bundle , msg ) ; } else { for ( Iterator < PlaceObject > iter = _plreg . enumeratePlaces ( ) ; iter . hasNext ( ) ; ) { PlaceObject plobj = iter . next ( ) ; if ( plobj . shouldBroadcast ( ) ) { broadcastTo ( plobj , from , levelOrMode , bundle , msg ) ; } } } if ( forward && _chatForwarder != null ) { _chatForwarder . forwardBroadcast ( from , levelOrMode , bundle , msg ) ; } } | Broadcast with support for a customizable level or mode . |
13,603 | public void deliverTell ( UserMessage message , Name target , TellListener listener ) throws InvocationException { BodyObject tobj = _locator . lookupBody ( target ) ; if ( tobj == null ) { if ( _chatForwarder != null && _chatForwarder . forwardTell ( message , target , listener ) ) { return ; } throw new InvocationException ( ChatCodes . USER_NOT_ONLINE ) ; } if ( tobj . status == OccupantInfo . DISCONNECTED ) { String errmsg = MessageBundle . compose ( ChatCodes . USER_DISCONNECTED , TimeUtil . getTimeOrderString ( System . currentTimeMillis ( ) - tobj . getLocal ( BodyLocal . class ) . statusTime , TimeUtil . SECOND ) ) ; throw new InvocationException ( errmsg ) ; } deliverTell ( tobj , message ) ; long idle = 0L ; if ( tobj . status == OccupantInfo . IDLE ) { idle = System . currentTimeMillis ( ) - tobj . getLocal ( BodyLocal . class ) . statusTime ; } String awayMessage = null ; if ( ! StringUtil . isBlank ( tobj . awayMessage ) ) { awayMessage = tobj . awayMessage ; } listener . tellSucceeded ( idle , awayMessage ) ; } | Delivers a tell message to the specified target and notifies the supplied listener of the result . It is assumed that the teller has already been permissions checked . |
13,604 | public void deliverTell ( BodyObject target , UserMessage message ) { SpeakUtil . sendMessage ( target , message ) ; SpeakUtil . noteMessage ( target , message . speaker , message ) ; } | Delivers a tell notification to the specified target player . It is assumed that the message is coming from some server entity and need not be permissions checked or notified of the result . |
13,605 | protected void broadcastTo ( DObject object , Name from , byte levelOrMode , String bundle , String msg ) { if ( from == null ) { SpeakUtil . sendSystem ( object , bundle , msg , levelOrMode ) ; } else { SpeakUtil . sendSpeak ( object , from , bundle , msg , levelOrMode ) ; } } | Direct a broadcast to the specified object . |
13,606 | public void appendReport ( StringBuilder report , long now , long sinceLast , boolean reset ) { PresentsConMgrStats stats = getStats ( ) ; long eventCount = stats . eventCount - _lastStats . eventCount ; int connects = stats . connects - _lastStats . connects ; int disconnects = stats . disconnects - _lastStats . disconnects ; int closes = stats . closes - _lastStats . closes ; long bytesIn = stats . bytesIn - _lastStats . bytesIn ; long bytesOut = stats . bytesOut - _lastStats . bytesOut ; long msgsIn = stats . msgsIn - _lastStats . msgsIn ; long msgsOut = stats . msgsOut - _lastStats . msgsOut ; if ( reset ) { _lastStats = stats ; } sinceLast = Math . max ( sinceLast , 1L ) ; report . append ( "* presents.net.ConnectionManager:\n" ) ; report . append ( "- Network connections: " ) ; report . append ( stats . connectionCount ) . append ( " connections, " ) ; report . append ( stats . handlerCount ) . append ( " handlers\n" ) ; report . append ( "- Network activity: " ) ; report . append ( eventCount ) . append ( " events, " ) ; report . append ( connects ) . append ( " connects, " ) ; report . append ( disconnects ) . append ( " disconnects, " ) ; report . append ( closes ) . append ( " closes\n" ) ; report . append ( "- Network input: " ) ; report . append ( bytesIn ) . append ( " bytes, " ) ; report . append ( msgsIn ) . append ( " msgs, " ) ; report . append ( msgsIn * 1000 / sinceLast ) . append ( " mps, " ) ; long avgIn = ( msgsIn == 0 ) ? 0 : ( bytesIn / msgsIn ) ; report . append ( avgIn ) . append ( " avg size, " ) ; report . append ( bytesIn * 1000 / sinceLast ) . append ( " bps\n" ) ; report . append ( "- Network output: " ) ; report . append ( bytesOut ) . append ( " bytes, " ) ; report . append ( msgsOut ) . append ( " msgs, " ) ; report . append ( msgsOut * 1000 / sinceLast ) . append ( " mps, " ) ; long avgOut = ( msgsOut == 0 ) ? 0 : ( bytesOut / msgsOut ) ; report . append ( avgOut ) . append ( " avg size, " ) ; report . append ( bytesOut * 1000 / sinceLast ) . append ( " bps\n" ) ; } | from interface ReportManager . Reporter |
13,607 | public boolean setPrivateKey ( PrivateKey key ) { if ( SecureUtil . ciphersSupported ( key ) ) { _privateKey = key ; return true ; } return false ; } | Sets the private key if the ciphers are supported . |
13,608 | protected int handleDatagram ( DatagramChannel listener , long when ) { InetSocketAddress source ; _databuf . clear ( ) ; try { source = ( InetSocketAddress ) listener . receive ( _databuf ) ; } catch ( IOException ioe ) { log . warning ( "Failure receiving datagram." , ioe ) ; return 0 ; } if ( source == null ) { log . info ( "Psych! Got READ_READY, but no datagram." ) ; return 0 ; } int size = _databuf . flip ( ) . remaining ( ) ; if ( size < 14 ) { log . warning ( "Received undersized datagram" , "source" , source , "size" , size ) ; return 0 ; } int connectionId = _databuf . getInt ( ) ; Connection conn = _connections . get ( connectionId ) ; if ( conn != null ) { ( ( PresentsConnection ) conn ) . handleDatagram ( source , listener , _databuf , when ) ; } else { log . debug ( "Received datagram for unknown connection" , "id" , connectionId , "source" , source ) ; } return size ; } | Called when a datagram message is ready to be read off its channel . |
13,609 | public void openOutgoingConnection ( Connection conn , String hostname , int port ) throws IOException { SocketChannel sockchan = SocketChannel . open ( ) ; sockchan . configureBlocking ( false ) ; conn . init ( this , sockchan , System . currentTimeMillis ( ) ) ; _connectq . append ( Tuple . newTuple ( conn , new InetSocketAddress ( hostname , port ) ) ) ; } | Opens an outgoing connection to the supplied address . The connection will be opened in a non - blocking manner and added to the connection manager s select set . Messages posted to the connection prior to it being actually connected to its destination will remain in the queue . If the connection fails those messages will be dropped . |
13,610 | protected void startOutgoingConnection ( final Connection conn , InetSocketAddress addr ) { final SocketChannel sockchan = conn . getChannel ( ) ; try { conn . selkey = sockchan . register ( _selector , SelectionKey . OP_CONNECT ) ; NetEventHandler handler ; if ( sockchan . connect ( addr ) ) { _outConnValidator . validateOutgoing ( sockchan ) ; handler = conn ; } else { handler = new OutgoingConnectionHandler ( conn ) ; } _handlers . put ( conn . selkey , handler ) ; } catch ( IOException ioe ) { log . warning ( "Failed to initiate connection for " + sockchan + "." , ioe ) ; conn . connectFailure ( ioe ) ; } } | Starts the connection process for an outgoing connection . This is called as part of the conmgr tick for any pending outgoing connections . |
13,611 | protected void processAuthedConnections ( long iterStamp ) { AuthingConnection conn ; while ( ( conn = _authq . getNonBlocking ( ) ) != null ) { try { PresentsConnection rconn = new PresentsConnection ( ) ; rconn . init ( this , conn . getChannel ( ) , iterStamp ) ; rconn . selkey = conn . selkey ; rconn . inheritStreams ( conn ) ; _handlers . put ( rconn . selkey , rconn ) ; _connections . put ( rconn . getConnectionId ( ) , rconn ) ; rconn . setDatagramSecret ( conn . getAuthRequest ( ) . getCredentials ( ) . getDatagramSecret ( ) ) ; OverflowQueue oflowHandler = _oflowqs . remove ( conn ) ; if ( oflowHandler != null ) { _oflowqs . put ( rconn , oflowHandler ) ; } _clmgr . connectionEstablished ( rconn , conn . getAuthName ( ) , conn . getAuthRequest ( ) , conn . getAuthResponse ( ) ) ; } catch ( IOException ioe ) { log . warning ( "Failure upgrading authing connection to running." , ioe ) ; } } } | Converts connections that have completed the authentication process into full running connections and notifies the client manager that new connections have been established . |
13,612 | protected boolean writeDatagram ( PresentsConnection conn , byte [ ] data ) { InetSocketAddress target = conn . getDatagramAddress ( ) ; if ( target == null ) { log . warning ( "No address to send datagram" , "conn" , conn ) ; return false ; } _databuf . clear ( ) ; _databuf . put ( data ) . flip ( ) ; try { return conn . getDatagramChannel ( ) . send ( _databuf , target ) > 0 ; } catch ( IOException ioe ) { log . warning ( "Failed to send datagram." , ioe ) ; return false ; } } | Sends a datagram to the specified connection . |
13,613 | public OccupantInfo getOccupantInfo ( Name username ) { try { for ( OccupantInfo info : occupantInfo ) { if ( info . username . equals ( username ) ) { return info ; } } } catch ( Throwable t ) { log . warning ( "PlaceObject.getOccupantInfo choked." , t ) ; } return null ; } | Looks up a user s occupant info by name . |
13,614 | public static double getJulianDayNumber ( Calendar time ) { if ( time == null ) { time = GregorianCalendar . getInstance ( TimeZone . getTimeZone ( "GMT" ) ) ; } double jd = BASE_JD + time . getTimeInMillis ( ) / MILLISEC_PER_DAY ; return jd ; } | Calculate the Julian day number corresponding to the time provided |
13,615 | protected final int decodeLength ( ) { if ( _have < HEADER_SIZE ) { return - 1 ; } _buffer . rewind ( ) ; int length = ( _buffer . get ( ) & 0xFF ) << 24 ; length += ( _buffer . get ( ) & 0xFF ) << 16 ; length += ( _buffer . get ( ) & 0xFF ) << 8 ; length += ( _buffer . get ( ) & 0xFF ) ; _buffer . position ( _have ) ; return length ; } | Decodes and returns the length of the current frame from the buffer if possible . Returns - 1 otherwise . |
13,616 | public static void addExistingImports ( String asFile , ImportSet imports ) { Matcher m = AS_PUBLIC_CLASS_DECL . matcher ( asFile ) ; int searchTo = asFile . length ( ) ; if ( m . find ( ) ) { searchTo = m . start ( ) ; } m = AS_IMPORT . matcher ( asFile . substring ( 0 , searchTo ) ) ; while ( m . find ( ) ) { imports . add ( m . group ( 3 ) ) ; } } | Adds an existing ActionScript file s imports to the given ImportSet . |
13,617 | public static void convertBaseClasses ( ImportSet imports ) { imports . replace ( "byte" , "com.threerings.util.Byte" ) ; imports . replace ( "boolean" , "com.threerings.util.langBoolean" ) ; imports . replace ( "[B" , "flash.utils.ByteArray" ) ; imports . replace ( "float" , "com.threerings.util.Float" ) ; imports . replace ( "long" , "com.threerings.util.Long" ) ; if ( imports . removeAll ( "[*" ) > 0 ) { imports . add ( "com.threerings.io.TypedArray" ) ; } imports . replace ( Integer . class , "com.threerings.util.Integer" ) ; imports . replace ( Map . class , "com.threerings.util.Map" ) ; imports . removeGlobals ( ) ; imports . removeArrays ( ) ; } | Converts java types to their actionscript equivalents for ooo - style streaming . |
13,618 | public void noteClassMappingsReceived ( Collection < Class < ? > > sclasses ) { if ( _classmap == null ) { throw new RuntimeException ( "Missing class map" ) ; } for ( Class < ? > sclass : sclasses ) { ClassMapping cmap = _classmap . get ( sclass ) ; if ( cmap == null ) { throw new RuntimeException ( "No class mapping for " + sclass . getName ( ) ) ; } cmap . code = ( short ) Math . abs ( cmap . code ) ; } } | Notes that the receiver has received the mappings for a group of classes and thus that from now on only the codes need be sent . |
13,619 | public void noteInternMappingsReceived ( Collection < String > sinterns ) { if ( _internmap == null ) { throw new RuntimeException ( "Missing intern map" ) ; } for ( String sintern : sinterns ) { Short code = _internmap . get ( sintern ) ; if ( code == null ) { throw new RuntimeException ( "No intern mapping for " + sintern ) ; } short scode = code ; if ( scode < 0 ) { _internmap . put ( sintern , ( short ) - code ) ; } } } | Notes that the receiver has received the mappings for a group of interns and thus that from now on only the codes need be sent . |
13,620 | public void write ( int b ) throws IOException { int newcount = count + 1 ; if ( newcount > buf . length ) { buf = Arrays . copyOf ( buf , oversize ( newcount ) ) ; } buf [ count ] = ( byte ) b ; count = newcount ; } | Write an integer . |
13,621 | public void write ( byte [ ] b , int offset , int length ) throws IOException { if ( length == 0 ) { return ; } int newcount = count + length ; if ( newcount > buf . length ) { buf = Arrays . copyOf ( buf , oversize ( newcount ) ) ; } System . arraycopy ( b , offset , buf , count , length ) ; count = newcount ; } | Write byte array . |
13,622 | public void skip ( int length ) { int newcount = count + length ; if ( newcount > buf . length ) { buf = Arrays . copyOf ( buf , oversize ( newcount ) ) ; } count = newcount ; } | Skip a number of bytes . |
13,623 | public void parseEvents ( MarcXchangeEventConsumer consumer ) throws XMLStreamException { Objects . requireNonNull ( consumer ) ; if ( builder . getMarcListeners ( ) != null ) { for ( Map . Entry < String , MarcListener > entry : builder . getMarcListeners ( ) . entrySet ( ) ) { consumer . setMarcListener ( entry . getKey ( ) , entry . getValue ( ) ) ; } } XMLInputFactory inputFactory = XMLInputFactory . newInstance ( ) ; XMLEventReader xmlEventReader = inputFactory . createXMLEventReader ( builder . getInputStream ( ) ) ; while ( xmlEventReader . hasNext ( ) ) { consumer . add ( xmlEventReader . nextEvent ( ) ) ; } xmlEventReader . close ( ) ; } | Run XML stream parser over an XML input stream with an XML event consumer . |
13,624 | public int wrapFields ( String type , ChunkStream < byte [ ] , BytesReference > stream , boolean withCollection ) throws IOException { int count = 0 ; MarcListener marcListener = builder . getMarcListener ( type ) ; if ( marcListener == null ) { return count ; } try { if ( withCollection ) { if ( marcListener instanceof ContentHandler ) { ( ( ContentHandler ) marcListener ) . startDocument ( ) ; } marcListener . beginCollection ( ) ; } if ( builder . marcGenerator == null ) { builder . marcGenerator = builder . createGenerator ( ) ; } Chunk < byte [ ] , BytesReference > chunk ; while ( ( chunk = stream . readChunk ( ) ) != null ) { builder . marcGenerator . chunk ( chunk ) ; count ++ ; } stream . close ( ) ; builder . marcGenerator . flush ( ) ; if ( withCollection ) { marcListener . endCollection ( ) ; if ( marcListener instanceof ContentHandler ) { ( ( ContentHandler ) marcListener ) . endDocument ( ) ; } } } catch ( SAXException e ) { throw new IOException ( e ) ; } finally { if ( builder . getInputStream ( ) != null ) { builder . getInputStream ( ) . close ( ) ; } } return count ; } | Pass a given chunk stream to a MARC generator chunk by chunk . Can process any MARC streams not only separator streams . |
13,625 | public long wrapRecords ( ChunkStream < byte [ ] , BytesReference > stream , boolean withCollection ) throws IOException { final AtomicInteger l = new AtomicInteger ( ) ; try { MarcRecordListener marcRecordListener = builder . getMarcRecordListener ( ) ; if ( withCollection ) { if ( marcRecordListener instanceof ContentHandler ) { ( ( ContentHandler ) marcRecordListener ) . startDocument ( ) ; } marcRecordListener . beginCollection ( ) ; } if ( builder . marcGenerator == null ) { builder . marcGenerator = builder . createGenerator ( ) ; } builder . marcGenerator . setMarcListener ( builder ) ; builder . marcGenerator . setCharset ( builder . getCharset ( ) ) ; builder . stream = stream ; builder . recordStream ( ) . forEach ( record -> { marcRecordListener . record ( record ) ; l . incrementAndGet ( ) ; } ) ; stream . close ( ) ; builder . marcGenerator . flush ( ) ; if ( withCollection ) { marcRecordListener . endCollection ( ) ; if ( marcRecordListener instanceof ContentHandler ) { ( ( ContentHandler ) marcRecordListener ) . endDocument ( ) ; } } } catch ( SAXException e ) { throw new IOException ( e ) ; } finally { if ( builder . getInputStream ( ) != null ) { builder . getInputStream ( ) . close ( ) ; } } return l . get ( ) ; } | Wrap records into a collection . Can process any MARC streams not only separator streams . |
13,626 | protected void gotAuthResponse ( AuthResponse rsp ) throws LogonException { AuthResponseData data = rsp . getData ( ) ; if ( ! data . code . equals ( AuthResponseData . SUCCESS ) ) { throw new LogonException ( data . code ) ; } logonSucceeded ( data ) ; } | Subclasses must call this method when they receive the authentication response . |
13,627 | public void setAccessor ( Accessor < E > accessor ) { removeAll ( ) ; _accessor = accessor ; _table = new ObjectEditorTable ( _entryClass , _editableFields , _accessor . getInterp ( _interp ) , _displayFields ) ; add ( new JScrollPane ( _table ) , BorderLayout . CENTER ) ; } | Sets the logic for how this editor interacts with its underlying data . |
13,628 | protected void addEntry ( E entry ) { if ( _entryFilter == null || _entryFilter . apply ( entry ) ) { int index = _keys . insertSorted ( getKey ( entry ) ) ; _table . insertDatum ( entry , index ) ; } } | Handles the addition of an entry assuming our filter allows it . |
13,629 | protected void removeKey ( Comparable < ? > key ) { int index = _keys . indexOf ( key ) ; if ( index != - 1 ) { _keys . remove ( index ) ; _table . removeDatum ( index ) ; } } | Takes care of removing a key from |
13,630 | public void actionPerformed ( ActionEvent event ) { CommandEvent ce = ( CommandEvent ) event ; _accessor . updateEntry ( _setName , ( DSet . Entry ) ce . getArgument ( ) ) ; } | documentation inherited from interface ActionListener |
13,631 | public void clear ( String layerName ) { synchronized ( this ) { log . info ( "clearing cache for layer " + layerName ) ; for ( String key : cache . keySet ( ) ) { if ( key . contains ( layerName ) ) remove ( key ) ; } } } | TOOD improve this |
13,632 | public synchronized void put ( WmsRequest request , byte [ ] image ) { synchronized ( this ) { String key = getKey ( request ) ; keys . remove ( key ) ; keys . add ( key ) ; if ( keys . size ( ) > maxSize ) remove ( keys . get ( 0 ) ) ; if ( maxSize > 0 && layers . containsAll ( request . getLayers ( ) ) ) { cache . put ( key , image ) ; log . info ( "cached image with key=" + key ) ; } } } | Sets the cached image for the request . |
13,633 | public static String cloneArgument ( Class < ? > dsclazz , Field field , String name ) { Class < ? > clazz = field . getType ( ) ; if ( clazz . isArray ( ) || dsclazz . equals ( clazz ) ) { return "(" + name + " == null) ? null : " + name + ".clone()" ; } else if ( dsclazz . isAssignableFrom ( clazz ) ) { return "(" + name + " == null) ? null : " + "(" + simpleName ( field ) + ")" + name + ".clone()" ; } else { return name ; } } | Potentially clones the supplied argument if it is the type that needs such treatment . |
13,634 | public static String readClassName ( File source ) throws IOException { String pkgname = null , name = null ; BufferedReader bin = new BufferedReader ( new FileReader ( source ) ) ; String line ; while ( ( line = bin . readLine ( ) ) != null ) { Matcher pm = PACKAGE_PATTERN . matcher ( line ) ; if ( pm . find ( ) ) { pkgname = pm . group ( 1 ) ; } Matcher nm = NAME_PATTERN . matcher ( line ) ; if ( nm . find ( ) ) { name = nm . group ( 2 ) ; break ; } } bin . close ( ) ; if ( name == null ) { throw new IOException ( "Unable to locate class or interface name in " + source + "." ) ; } if ( pkgname != null ) { name = pkgname + "." + name ; } return name ; } | Reads in the supplied source file and locates the package and class or interface name and returns a fully qualified class name . |
13,635 | public void bodyRemovedFromChannel ( ChatChannel channel , final int bodyId ) { _peerMan . invokeNodeAction ( new ChannelAction ( channel ) { protected void execute ( ) { ChannelInfo info = _channelMan . _channels . get ( _channel ) ; if ( info != null ) { info . participants . remove ( bodyId ) ; } else if ( _channelMan . _resolving . containsKey ( _channel ) ) { log . warning ( "Oh for fuck's sake, distributed systems are complicated" , "channel" , _channel ) ; } } } ) ; } | When a body loses channel membership this method should be called so that any server that happens to be hosting that channel can be told that the body in question is now a participant . |
13,636 | public void collectChatHistory ( final Name user , final ResultListener < ChatHistoryResult > lner ) { _peerMan . invokeNodeRequest ( new NodeRequest ( ) { public boolean isApplicable ( NodeObject nodeobj ) { return true ; } protected void execute ( InvocationService . ResultListener listener ) { listener . requestProcessed ( Lists . newArrayList ( Iterables . filter ( _chatHistory . get ( user ) , IS_USER_MESSAGE ) ) ) ; } protected transient ChatHistory _chatHistory ; } , new NodeRequestsListener < List < ChatHistory . Entry > > ( ) { public void requestsProcessed ( NodeRequestsResult < List < ChatHistory . Entry > > rRes ) { ChatHistoryResult chRes = new ChatHistoryResult ( ) ; chRes . failedNodes = rRes . getNodeErrors ( ) . keySet ( ) ; chRes . history = Lists . newArrayList ( Iterables . concat ( rRes . getNodeResults ( ) . values ( ) ) ) ; Collections . sort ( chRes . history , SORT_BY_TIMESTAMP ) ; lner . requestCompleted ( chRes ) ; } public void requestFailed ( String cause ) { lner . requestFailed ( new InvocationException ( cause ) ) ; } } ) ; } | Collects all chat messages heard by the given user on all peers . |
13,637 | public void speak ( ClientObject caller , final ChatChannel channel , String message , byte mode ) { BodyObject body = _locator . forClient ( caller ) ; final UserMessage umsg = new UserMessage ( body . getVisibleName ( ) , null , message , mode ) ; if ( _channels . containsKey ( channel ) ) { dispatchSpeak ( channel , umsg ) ; return ; } List < UserMessage > msgs = _resolving . get ( channel ) ; if ( msgs != null ) { msgs . add ( umsg ) ; return ; } _peerMan . invokeNodeAction ( new ChannelAction ( channel ) { protected void execute ( ) { _channelMan . dispatchSpeak ( _channel , umsg ) ; } } , new Runnable ( ) { public void run ( ) { _resolving . put ( channel , Lists . newArrayList ( umsg ) ) ; resolveAndDispatch ( channel ) ; } } ) ; } | from interface ChannelSpeakProvider |
13,638 | protected void resolveAndDispatch ( final ChatChannel channel ) { NodeObject . Lock lock = new NodeObject . Lock ( "ChatChannel" , channel . getLockName ( ) ) ; _peerMan . performWithLock ( lock , new PeerManager . LockedOperation ( ) { public void run ( ) { ( ( CrowdNodeObject ) _peerMan . getNodeObject ( ) ) . addToHostedChannels ( channel ) ; finishResolveAndDispatch ( channel ) ; } public void fail ( String peerName ) { final List < UserMessage > msgs = _resolving . remove ( channel ) ; if ( peerName == null ) { log . warning ( "Failed to resolve chat channel due to lock failure" , "channel" , channel ) ; } else { _peerMan . invokeNodeAction ( peerName , new ChannelAction ( channel ) { protected void execute ( ) { for ( final UserMessage msg : msgs ) { _channelMan . dispatchSpeak ( _channel , msg ) ; } } } ) ; } } } ) ; } | Resolves the channel specified in the supplied action and then dispatches it . |
13,639 | protected void resolutionComplete ( ChatChannel channel , Set < Integer > parts ) { ChannelInfo info = new ChannelInfo ( ) ; info . channel = channel ; info . participants = parts ; _channels . put ( channel , info ) ; for ( UserMessage msg : _resolving . remove ( channel ) ) { dispatchSpeak ( channel , msg ) ; } } | This should be called when a channel s participant set has been resolved . |
13,640 | protected void resolutionFailed ( ChatChannel channel , Exception cause ) { log . warning ( "Failed to resolve chat channel" , "channel" , channel , cause ) ; _resolving . remove ( channel ) ; } | This should be called if channel resolution fails . |
13,641 | protected void dispatchSpeak ( ChatChannel channel , final UserMessage message ) { final ChannelInfo info = _channels . get ( channel ) ; if ( info == null ) { log . warning ( "Requested to dispatch speak on unhosted channel" , "channel" , channel , "msg" , message ) ; return ; } if ( ! info . participants . contains ( getBodyId ( message . speaker ) ) ) { log . warning ( "Dropping channel chat message from non-speaker" , "channel" , channel , "message" , message ) ; return ; } info . lastMessage = System . currentTimeMillis ( ) ; final Map < String , int [ ] > partMap = Maps . newHashMap ( ) ; for ( NodeObject nodeobj : _peerMan . getNodeObjects ( ) ) { ArrayIntSet nodeBodyIds = new ArrayIntSet ( ) ; for ( ClientInfo clinfo : nodeobj . clients ) { int bodyId = getBodyId ( ( ( CrowdClientInfo ) clinfo ) . visibleName ) ; if ( info . participants . contains ( bodyId ) ) { nodeBodyIds . add ( bodyId ) ; } } partMap . put ( nodeobj . nodeName , nodeBodyIds . toIntArray ( ) ) ; } for ( Map . Entry < String , int [ ] > entry : partMap . entrySet ( ) ) { final int [ ] bodyIds = entry . getValue ( ) ; _peerMan . invokeNodeAction ( entry . getKey ( ) , new ChannelAction ( channel ) { protected void execute ( ) { _channelMan . deliverSpeak ( _channel , message , bodyIds ) ; } } ) ; } } | Requests that we dispatch the supplied message to all participants of the specified chat channel . The speaker will be validated prior to dispatching the message as the originating server does not have the information it needs to validate the speaker and must leave that to us the channel hosting server . |
13,642 | protected void deliverSpeak ( ChatChannel channel , UserMessage message , int [ ] bodyIds ) { channel = intern ( channel ) ; for ( int bodyId : bodyIds ) { BodyObject bobj = getBodyObject ( bodyId ) ; if ( bobj != null && shouldDeliverSpeak ( channel , message , bobj ) ) { _chatHistory . record ( channel , bobj . getChatIdentifier ( message ) , message , bobj . getVisibleName ( ) ) ; bobj . postMessage ( ChatCodes . CHAT_CHANNEL_NOTIFICATION , channel , message ) ; } } } | Delivers the supplied chat channel message to the specified bodies . |
13,643 | protected void closeIdleChannels ( ) { long now = System . currentTimeMillis ( ) ; Iterator < Map . Entry < ChatChannel , ChannelInfo > > iter = _channels . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Map . Entry < ChatChannel , ChannelInfo > entry = iter . next ( ) ; if ( now - entry . getValue ( ) . lastMessage > IDLE_CHANNEL_CLOSE_TIME ) { ( ( CrowdNodeObject ) _peerMan . getNodeObject ( ) ) . removeFromHostedChannels ( entry . getKey ( ) ) ; iter . remove ( ) ; } } } | Called periodically to check for and close any channels that have been idle too long . |
13,644 | protected ChatChannel intern ( ChatChannel channel ) { ChannelInfo chinfo = _channels . get ( channel ) ; if ( chinfo != null ) { return chinfo . channel ; } return channel ; } | Returns a widely referenced instance equivalent to the given channel if one is available . This reduces memory usage since clients send new channel instances with each message . |
13,645 | public static < E extends Enum < E > > StreamableEnumSet < E > noneOf ( Class < E > elementType ) { return new StreamableEnumSet < E > ( elementType ) ; } | Creates an empty set of the specified type . |
13,646 | public static < E extends Enum < E > > StreamableEnumSet < E > allOf ( Class < E > elementType ) { StreamableEnumSet < E > set = new StreamableEnumSet < E > ( elementType ) ; for ( E constant : elementType . getEnumConstants ( ) ) { set . add ( constant ) ; } return set ; } | Creates a set containing all elements of the specified type . |
13,647 | public static < E extends Enum < E > > StreamableEnumSet < E > copyOf ( StreamableEnumSet < E > s ) { return s . clone ( ) ; } | Creates a set containing all elements in the set provided . |
13,648 | public static < E extends Enum < E > > StreamableEnumSet < E > of ( E first , E ... rest ) { StreamableEnumSet < E > set = new StreamableEnumSet < E > ( first . getDeclaringClass ( ) ) ; set . add ( first ) ; for ( E e : rest ) { set . add ( e ) ; } return set ; } | Creates a set consisting of the specified elements . |
13,649 | public boolean add ( int oid ) { for ( int ii = 0 ; ii < _size ; ii ++ ) { if ( _oids [ ii ] == oid ) { return false ; } } if ( _size + 1 >= _oids . length ) { expand ( ) ; } _oids [ _size ++ ] = oid ; return true ; } | Adds the specified object id to the list if it is not already there . |
13,650 | public boolean remove ( int oid ) { for ( int ii = 0 ; ii < _size ; ii ++ ) { if ( _oids [ ii ] == oid ) { System . arraycopy ( _oids , ii + 1 , _oids , ii , -- _size - ii ) ; return true ; } } return false ; } | Removes the specified oid from the list . |
13,651 | public boolean contains ( int oid ) { for ( int ii = 0 ; ii < _size ; ii ++ ) { if ( _oids [ ii ] == oid ) { return true ; } } return false ; } | Returns true if the specified oid is in the list false if not . |
13,652 | public JPanel getEditor ( PresentsContext ctx , Field field ) { if ( field . getType ( ) . equals ( Boolean . TYPE ) ) { return new BooleanFieldEditor ( ctx , field , this ) ; } else { return new AsStringFieldEditor ( ctx , field , this ) ; } } | Returns the editor panel for the specified field . |
13,653 | public void getConfigInfo ( AdminService . ConfigInfoListener arg1 ) { AdminMarshaller . ConfigInfoMarshaller listener1 = new AdminMarshaller . ConfigInfoMarshaller ( ) ; listener1 . listener = arg1 ; sendRequest ( GET_CONFIG_INFO , new Object [ ] { listener1 } ) ; } | from interface AdminService |
13,654 | public void dispatchRequest ( ClientObject source , int methodId , Object [ ] args ) throws InvocationException { log . warning ( "Requested to dispatch unknown method" , "provider" , provider , "sourceOid" , source . getOid ( ) , "methodId" , methodId , "args" , args ) ; } | Dispatches the specified method to our provider . |
13,655 | public void speak ( String arg1 , byte arg2 ) { sendRequest ( SPEAK , new Object [ ] { arg1 , Byte . valueOf ( arg2 ) } ) ; } | from interface SpeakService |
13,656 | public static boolean isBlank ( Name name ) { return ( name == null || name . toString ( ) . equals ( BLANK . toString ( ) ) ) ; } | Returns true if this name is null or blank false if it contains useful data . This works on derived classes as well . |
13,657 | public String getNormal ( ) { if ( _normal == null ) { _normal = normalize ( _name ) ; if ( _normal . equals ( _name ) ) { _normal = _name ; } } return _normal ; } | Returns the normalized version of this name . |
13,658 | public boolean scheduleRegularReboot ( ) { int freq = getDayFrequency ( ) ; int hour = getRebootHour ( ) ; if ( freq <= 0 ) { return false ; } Calendars . Builder cal = Calendars . now ( ) ; int curHour = cal . get ( Calendar . HOUR_OF_DAY ) ; cal = cal . zeroTime ( ) . addHours ( hour ) . addDays ( ( curHour < hour ) ? ( freq - 1 ) : freq ) ; if ( getSkipWeekends ( ) ) { switch ( cal . get ( Calendar . DAY_OF_WEEK ) ) { case Calendar . SATURDAY : cal . addDays ( 2 ) ; break ; case Calendar . SUNDAY : cal . addDays ( 1 ) ; break ; } } scheduleReboot ( cal . toTime ( ) , true , AUTOMATIC_INITIATOR ) ; return true ; } | Schedules our next regularly scheduled reboot . |
13,659 | public void cancelReboot ( ) { if ( _interval != null ) { _interval . cancel ( ) ; _interval = null ; } _nextReboot = 0L ; _rebootSoon = false ; _initiator = null ; } | Cancel the currently scheduled reboot if any . |
13,660 | public int preventReboot ( String whereFrom ) { if ( whereFrom == null ) { throw new IllegalArgumentException ( "whereFrom must be descriptive." ) ; } int lockId = _nextRebootLockId ++ ; _rebootLocks . put ( lockId , whereFrom ) ; return lockId ; } | Called by an entity that would like to prevent a reboot . |
13,661 | protected void scheduleReboot ( long rebootTime , boolean exact , String initiator ) { cancelReboot ( ) ; long now = System . currentTimeMillis ( ) ; rebootTime = Math . max ( rebootTime , now ) ; long delay = rebootTime - now ; int [ ] warnings = getWarnings ( ) ; int level = - 1 ; for ( int ii = warnings . length - 1 ; ii >= 0 ; ii -- ) { long warnTime = warnings [ ii ] * ( 60L * 1000L ) ; if ( delay <= warnTime ) { level = ii ; if ( ! exact ) { rebootTime = now + warnTime ; } break ; } } _nextReboot = rebootTime ; _initiator = initiator ; doWarning ( level , ( int ) ( ( rebootTime - now ) / ( 60L * 1000L ) ) ) ; } | Schedule a reboot . |
13,662 | protected String getRebootMessage ( String key , int minutes ) { String msg = getCustomRebootMessage ( ) ; if ( StringUtil . isBlank ( msg ) ) { msg = "m.reboot_msg_standard" ; } return MessageBundle . compose ( key , MessageBundle . taint ( "" + minutes ) , msg ) ; } | Composes the given reboot message with the minutes and either the custom or standard details about the pending reboot . |
13,663 | protected void doWarning ( int level , int minutes ) { _rebootSoon = ( level > - 1 ) ; int [ ] warnings = getWarnings ( ) ; if ( level == warnings . length ) { if ( checkLocks ( ) ) { return ; } log . info ( "Performing automatic server reboot/shutdown, as scheduled by: " + _initiator ) ; broadcast ( "m.rebooting_now" ) ; new Interval ( Interval . RUN_DIRECT ) { public void expired ( ) { _server . queueShutdown ( ) ; } } . schedule ( 1000 ) ; return ; } if ( _rebootSoon ) { notifyObservers ( level ) ; broadcast ( getRebootMessage ( "m.reboot_warning" , minutes ) ) ; } final int nextLevel = level + 1 ; final int nextMinutes = ( nextLevel == warnings . length ) ? 0 : warnings [ nextLevel ] ; _interval = _omgr . newInterval ( new Runnable ( ) { public void run ( ) { doWarning ( nextLevel , nextMinutes ) ; } } ) ; _interval . schedule ( Math . max ( 0L , _nextReboot - ( nextMinutes * 60L * 1000L ) - System . currentTimeMillis ( ) ) ) ; } | Do a warning schedule the next . |
13,664 | protected boolean checkLocks ( ) { if ( _rebootLocks . isEmpty ( ) ) { return false ; } log . info ( "Reboot delayed due to outstanding locks" , "locks" , _rebootLocks . elements ( ) ) ; broadcast ( "m.reboot_delayed" ) ; ( _interval = _omgr . newInterval ( new Runnable ( ) { public void run ( ) { doWarning ( getWarnings ( ) . length , 0 ) ; } } ) ) . schedule ( 60 * 1000 ) ; return true ; } | Check to see if there are outstanding reboot locks that may delay the reboot returning false if there are none . |
13,665 | protected void notifyObservers ( int level ) { final int warningsLeft = getWarnings ( ) . length - level - 1 ; final long msLeft = _nextReboot - System . currentTimeMillis ( ) ; _observers . apply ( new ObserverList . ObserverOp < PendingShutdownObserver > ( ) { public boolean apply ( PendingShutdownObserver observer ) { observer . shutdownPlanned ( warningsLeft , msLeft ) ; return true ; } } ) ; } | Notify all PendingShutdownObservers of the pending shutdown! |
13,666 | public void registerFlushDelay ( Class < ? > objclass , long delay ) { _delays . put ( objclass , Long . valueOf ( delay ) ) ; } | Registers an object flush delay . |
13,667 | public void processMessage ( Message msg ) { if ( _client . getRunQueue ( ) . isRunning ( ) ) { _actions . append ( msg ) ; _client . getRunQueue ( ) . postRunnable ( this ) ; } else { log . info ( "Dropping message as RunQueue is shutdown" , "msg" , msg ) ; } } | Called by the communicator when a message arrives from the network layer . We queue it up for processing and request some processing time on the main thread . |
13,668 | public void cleanup ( ) { for ( PendingRequest < ? > req : _penders . values ( ) ) { for ( Subscriber < ? > sub : req . targets ) { sub . requestFailed ( req . oid , new ObjectAccessException ( "Client connection closed" ) ) ; } } _penders . clear ( ) ; _flusher . cancel ( ) ; _flushes . clear ( ) ; _dead . clear ( ) ; _client . getRunQueue ( ) . postRunnable ( new Runnable ( ) { public void run ( ) { _ocache . clear ( ) ; } } ) ; } | Called when the client is cleaned up due to having disconnected from the server . |
13,669 | protected void dispatchEvent ( DEvent event ) { int remoteOid = event . getTargetOid ( ) ; DObject target = _ocache . get ( remoteOid ) ; if ( target == null ) { if ( ! _dead . containsKey ( remoteOid ) ) { log . warning ( "Unable to dispatch event on non-proxied object " + event + "." ) ; } return ; } _client . convertFromRemote ( target , event ) ; if ( event instanceof CompoundEvent ) { target . notifyProxies ( event ) ; List < DEvent > events = ( ( CompoundEvent ) event ) . getEvents ( ) ; int ecount = events . size ( ) ; for ( int ii = 0 ; ii < ecount ; ii ++ ) { dispatchEvent ( remoteOid , target , events . get ( ii ) ) ; } } else { target . notifyProxies ( event ) ; dispatchEvent ( remoteOid , target , event ) ; } } | Called when a new event arrives from the server that should be dispatched to subscribers here on the client . |
13,670 | protected void dispatchEvent ( int remoteOid , DObject target , DEvent event ) { try { boolean notify = event . applyToObject ( target ) ; if ( event instanceof ObjectDestroyedEvent ) { _ocache . remove ( remoteOid ) ; } if ( notify ) { target . notifyListeners ( event ) ; } } catch ( Exception e ) { log . warning ( "Failure processing event" , "event" , event , "target" , target , e ) ; } } | Dispatches an event on an already resolved target object . |
13,671 | protected < T extends DObject > void registerObjectAndNotify ( ObjectResponse < T > orsp ) { T obj = orsp . getObject ( ) ; obj . setManager ( this ) ; _ocache . put ( obj . getOid ( ) , obj ) ; PendingRequest < ? > req = _penders . remove ( obj . getOid ( ) ) ; if ( req == null ) { log . warning ( "Got object, but no one cares?!" , "oid" , obj . getOid ( ) , "obj" , obj ) ; return ; } for ( int ii = 0 ; ii < req . targets . size ( ) ; ii ++ ) { @ SuppressWarnings ( "unchecked" ) Subscriber < T > target = ( Subscriber < T > ) req . targets . get ( ii ) ; obj . addSubscriber ( target ) ; target . objectAvailable ( obj ) ; } } | Registers this object in our proxy cache and notifies the subscribers that were waiting for subscription to this object . |
13,672 | protected void flushObject ( DObject obj ) { int ooid = obj . getOid ( ) ; _ocache . remove ( ooid ) ; _dead . put ( ooid , obj ) ; _comm . postMessage ( new UnsubscribeRequest ( ooid ) ) ; } | Flushes a distributed object subscription issuing an unsubscribe request to the server . |
13,673 | protected void flushObjects ( ) { long now = System . currentTimeMillis ( ) ; for ( Iterator < IntMap . IntEntry < FlushRecord > > iter = _flushes . intEntrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { IntMap . IntEntry < FlushRecord > entry = iter . next ( ) ; FlushRecord rec = entry . getValue ( ) ; if ( rec . expire <= now ) { iter . remove ( ) ; flushObject ( rec . object ) ; } } } | Called periodically to flush any objects that have been lingering due to a previously enacted flush delay . |
13,674 | public static Cipher getAESCipher ( int mode , byte [ ] key ) { try { Cipher cipher = Cipher . getInstance ( "AES/CBC/PKCS5Padding" ) ; SecretKeySpec aesKey = new SecretKeySpec ( key , "AES" ) ; cipher . init ( mode , aesKey , IVPS ) ; return cipher ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to create cipher" , gse ) ; } return null ; } | Creates our AES cipher . |
13,675 | public static Cipher getRSACipher ( int mode , Key key ) { try { Cipher cipher = Cipher . getInstance ( "RSA" ) ; cipher . init ( mode , key ) ; return cipher ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to create cipher" , gse ) ; } return null ; } | Creates our RSA cipher . |
13,676 | public static KeyPair genRSAKeyPair ( int bits ) { try { KeyPairGenerator kpg = KeyPairGenerator . getInstance ( "RSA" ) ; kpg . initialize ( bits ) ; return kpg . genKeyPair ( ) ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to create key pair" , gse ) ; } return null ; } | Creates an RSA key pair . |
13,677 | public static PublicKey stringToRSAPublicKey ( String str ) { try { BigInteger mod = new BigInteger ( str . substring ( 0 , str . indexOf ( SPLIT ) ) , 16 ) ; BigInteger exp = new BigInteger ( str . substring ( str . indexOf ( SPLIT ) + 1 ) , 16 ) ; RSAPublicKeySpec keySpec = new RSAPublicKeySpec ( mod , exp ) ; KeyFactory kf = KeyFactory . getInstance ( "RSA" ) ; return kf . generatePublic ( keySpec ) ; } catch ( NumberFormatException nfe ) { log . warning ( "Failed to read key from string." , "str" , str , nfe ) ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to read key from string." , "str" , str , gse ) ; } return null ; } | Creates a public key from the supplied string . |
13,678 | public static PrivateKey stringToRSAPrivateKey ( String str ) { try { BigInteger mod = new BigInteger ( str . substring ( 0 , str . indexOf ( SPLIT ) ) , 16 ) ; BigInteger exp = new BigInteger ( str . substring ( str . indexOf ( SPLIT ) + 1 ) , 16 ) ; RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec ( mod , exp ) ; KeyFactory kf = KeyFactory . getInstance ( "RSA" ) ; return kf . generatePrivate ( keySpec ) ; } catch ( NumberFormatException nfe ) { log . warning ( "Failed to read key from string." , "str" , str , nfe ) ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to read key from string." , "str" , str , gse ) ; } return null ; } | Creates a private key from the supplied string . |
13,679 | public static byte [ ] encryptBytes ( PublicKey key , byte [ ] secret , byte [ ] salt ) { byte [ ] encrypt = new byte [ secret . length + salt . length ] ; for ( int ii = 0 ; ii < secret . length ; ii ++ ) { encrypt [ ii ] = secret [ ii ] ; } for ( int ii = 0 ; ii < salt . length ; ii ++ ) { encrypt [ secret . length + ii ] = salt [ ii ] ; } try { return getRSACipher ( key ) . doFinal ( encrypt ) ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to encrypt bytes" , gse ) ; } return encrypt ; } | Encrypts a secret key and salt with a public key . |
13,680 | public static byte [ ] decryptBytes ( PrivateKey key , byte [ ] encrypted , byte [ ] salt ) { try { byte [ ] decrypted = getRSACipher ( key ) . doFinal ( encrypted ) ; for ( int ii = 0 ; ii < salt . length ; ii ++ ) { if ( decrypted [ decrypted . length - salt . length + ii ] != salt [ ii ] ) { return null ; } } byte [ ] secret = new byte [ decrypted . length - salt . length ] ; for ( int ii = 0 ; ii < secret . length ; ii ++ ) { secret [ ii ] = decrypted [ ii ] ; } return secret ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to decrypt bytes" , gse ) ; } return null ; } | Decrypts a secret key and checks for tailing salt . |
13,681 | public static byte [ ] xorBytes ( byte [ ] data , byte [ ] key ) { byte [ ] xored = new byte [ data . length ] ; for ( int ii = 0 ; ii < data . length ; ii ++ ) { xored [ ii ] = ( byte ) ( data [ ii ] ^ key [ ii % key . length ] ) ; } return xored ; } | XORs a byte array against a key . |
13,682 | public void commit ( ) { clearTarget ( ) ; int size = _events . size ( ) ; switch ( size ) { case 0 : break ; case 1 : _omgr . postEvent ( _events . get ( 0 ) ) ; break ; default : _transport = _events . get ( 0 ) . getTransport ( ) ; for ( int ii = 1 ; ii < size ; ii ++ ) { _transport = _events . get ( ii ) . getTransport ( ) . combine ( _transport ) ; } _omgr . postEvent ( this ) ; break ; } } | Commits this transaction by posting this event to the distributed object event queue . All participating dobjects will have their transaction references cleared and will go back to normal operation . |
13,683 | public PlaceConfig moveTo ( BodyObject source , int placeOid ) throws InvocationException { PlaceManager pmgr = _plreg . getPlaceManager ( placeOid ) ; if ( pmgr == null ) { log . info ( "Requested to move to non-existent place" , "who" , source . who ( ) , "placeOid" , placeOid ) ; throw new InvocationException ( NO_SUCH_PLACE ) ; } Place place = pmgr . getLocation ( ) ; if ( place . equals ( source . location ) ) { log . debug ( "Going along with client request to move to where they already are" , "source" , source . who ( ) , "place" , place ) ; return pmgr . getConfig ( ) ; } String errmsg ; if ( ( errmsg = pmgr . ratifyBodyEntry ( source ) ) != null ) { throw new InvocationException ( errmsg ) ; } if ( ! source . acquireLock ( "moveToLock" ) ) { throw new InvocationException ( MOVE_IN_PROGRESS ) ; } PresentsSession client = _clmgr . getClient ( source . username ) ; if ( client != null ) { client . setClassLoader ( pmgr . getClass ( ) . getClassLoader ( ) ) ; } try { source . startTransaction ( ) ; try { leaveOccupiedPlace ( source ) ; pmgr . bodyWillEnter ( source ) ; source . willEnterPlace ( place , pmgr . getPlaceObject ( ) ) ; } finally { source . commitTransaction ( ) ; } } finally { source . releaseLock ( "moveToLock" ) ; } return pmgr . getConfig ( ) ; } | Moves the specified body from whatever location they currently occupy to the location identified by the supplied place oid . |
13,684 | public void leaveOccupiedPlace ( BodyObject source ) { Place oldloc = source . location ; if ( oldloc == null ) { return ; } PlaceManager pmgr = _plreg . getPlaceManager ( oldloc . placeOid ) ; if ( pmgr == null ) { log . warning ( "Body requested to leave no longer existent place?" , "boid" , source . getOid ( ) , "place" , oldloc ) ; return ; } pmgr . bodyWillLeave ( source ) ; source . didLeavePlace ( pmgr . getPlaceObject ( ) ) ; } | Removes the specified body from the place object they currently occupy . Does nothing if the body is not currently in a place . |
13,685 | public void init ( int invOid , int invCode , InvocationDirector invDir ) { _invOid = invOid ; _invCode = invCode ; _invdir = invDir ; } | Initializes this invocation marshaller instance with the requisite information to allow it to operate in the wide world . This is called by the invocation manager when an invocation provider is registered and should not be called otherwise . |
13,686 | protected void sendRequest ( int methodId , Object [ ] args , Transport transport ) { _invdir . sendRequest ( _invOid , _invCode , methodId , args , transport ) ; } | Called by generated invocation marshaller code ; packages up and sends the specified invocation service request . |
13,687 | public static FieldMarshaller getFieldMarshaller ( Field field ) { if ( _marshallers == null ) { _marshallers = createMarshallers ( ) ; } if ( useFieldAccessors ( ) ) { Method reader = null , writer = null ; try { reader = field . getDeclaringClass ( ) . getMethod ( getReaderMethodName ( field . getName ( ) ) , READER_ARGS ) ; } catch ( NoSuchMethodException nsme ) { } try { writer = field . getDeclaringClass ( ) . getMethod ( getWriterMethodName ( field . getName ( ) ) , WRITER_ARGS ) ; } catch ( NoSuchMethodException nsme ) { } if ( reader != null && writer != null ) { return new MethodFieldMarshaller ( reader , writer ) ; } if ( ( reader == null && writer != null ) || ( writer == null && reader != null ) ) { log . warning ( "Class contains one but not both custom field reader and writer" , "class" , field . getDeclaringClass ( ) . getName ( ) , "field" , field . getName ( ) , "reader" , reader , "writer" , writer ) ; } } Class < ? > ftype = field . getType ( ) ; if ( ftype == String . class && field . isAnnotationPresent ( Intern . class ) ) { return _internMarshaller ; } FieldMarshaller fm = _marshallers . get ( ftype ) ; if ( fm == null ) { Class < ? > collClass = Streamer . getCollectionClass ( ftype ) ; if ( collClass != null && ! collClass . equals ( ftype ) ) { log . warning ( "Specific field types are discouraged " + "for Iterables/Collections and Maps. The implementation type may not be " + "recreated on the other side." , "class" , field . getDeclaringClass ( ) , "field" , field . getName ( ) , "type" , ftype , "shouldBe" , collClass ) ; fm = _marshallers . get ( collClass ) ; } if ( fm == null && ( ftype . isInterface ( ) || Streamer . isStreamable ( ftype ) ) ) { fm = _marshallers . get ( Streamable . class ) ; } } return fm ; } | Returns a field marshaller appropriate for the supplied field or null if no marshaller exists for the type contained by the field in question . |
13,688 | protected void sendOutgoingMessages ( long iterStamp ) { if ( _oflowqs . size ( ) > 0 ) { for ( OverflowQueue oq : _oflowqs . values ( ) . toArray ( new OverflowQueue [ _oflowqs . size ( ) ] ) ) { try { if ( oq . writeOverflowMessages ( iterStamp ) ) { _oflowqs . remove ( oq . conn ) ; } } catch ( IOException ioe ) { oq . conn . networkFailure ( ioe ) ; } } } Tuple < Connection , byte [ ] > tup ; while ( ( tup = _outq . getNonBlocking ( ) ) != null ) { Connection conn = tup . left ; OverflowQueue oqueue = _oflowqs . get ( conn ) ; if ( oqueue != null ) { int size = oqueue . size ( ) ; if ( ( size > 500 ) && ( size % 50 == 0 ) ) { log . warning ( "Aiya, big overflow queue for " + conn + "" , "size" , size , "bytes" , tup . right . length ) ; } oqueue . add ( tup . right ) ; continue ; } writeMessage ( conn , tup . right , _oflowHandler ) ; } } | Writes all queued overflow and normal messages to their respective sockets . Connections that already have established overflow queues will have their messages appended to their overflow queue instead so that they are delivered in the proper order . |
13,689 | protected boolean writeMessage ( Connection conn , byte [ ] data , PartialWriteHandler pwh ) { if ( conn . isClosed ( ) ) { return true ; } if ( data == ASYNC_CLOSE_REQUEST ) { closeConnection ( conn ) ; return true ; } if ( data . length > 1024 * 1024 ) { log . warning ( "Refusing to write very large message" , "conn" , conn , "size" , data . length ) ; return true ; } if ( data . length > _outbuf . capacity ( ) ) { int ncapacity = Math . max ( _outbuf . capacity ( ) << 1 , data . length ) ; log . info ( "Expanding output buffer size" , "nsize" , ncapacity ) ; _outbuf = ByteBuffer . allocateDirect ( ncapacity ) ; } boolean fully = true ; try { _outbuf . put ( data ) ; _outbuf . flip ( ) ; SocketChannel sochan = conn . getChannel ( ) ; if ( sochan . isConnectionPending ( ) ) { pwh . handlePartialWrite ( conn , _outbuf ) ; return false ; } int wrote = sochan . write ( _outbuf ) ; noteWrite ( 1 , wrote ) ; if ( _outbuf . remaining ( ) > 0 ) { fully = false ; pwh . handlePartialWrite ( conn , _outbuf ) ; } } catch ( NotYetConnectedException nyce ) { pwh . handlePartialWrite ( conn , _outbuf ) ; return false ; } catch ( IOException ioe ) { conn . networkFailure ( ioe ) ; } finally { _outbuf . clear ( ) ; } return fully ; } | Writes a message out to a connection passing the buck to the partial write handler if the entire message could not be written . |
13,690 | protected void connectionFailed ( Connection conn , IOException ioe ) { _handlers . remove ( conn . selkey ) ; _connections . remove ( conn . getConnectionId ( ) ) ; _oflowqs . remove ( conn ) ; synchronized ( this ) { _stats . disconnects ++ ; } } | Called by a connection if it experiences a network failure . |
13,691 | protected void connectionClosed ( Connection conn ) { _handlers . remove ( conn . selkey ) ; _connections . remove ( conn . getConnectionId ( ) ) ; _oflowqs . remove ( conn ) ; synchronized ( this ) { _stats . closes ++ ; } } | Called by a connection when it discovers that it s closed . |
13,692 | public static < K , V > StreamableHashMap < K , V > newMap ( Map < ? extends K , ? extends V > map ) { return new StreamableHashMap < K , V > ( map ) ; } | Creates StreamableHashMap populated with the same values as the provided Map . |
13,693 | public void shutdown ( ) { if ( _chatdir != null ) { _chatdir . removeChatFilter ( this ) ; _chatdir = null ; } _ctx . getClient ( ) . removeClientObserver ( this ) ; } | Called to shut down the mute director . |
13,694 | public void setMuted ( Name username , boolean mute ) { boolean changed = mute ? _mutelist . add ( username ) : _mutelist . remove ( username ) ; String feedback ; if ( mute ) { feedback = "m.muted" ; } else { feedback = changed ? "m.unmuted" : "m.notmuted" ; } _chatdir . displayFeedback ( null , MessageBundle . tcompose ( feedback , username ) ) ; if ( changed ) { notifyObservers ( username , mute ) ; } } | Mute or unmute the specified user . |
13,695 | public String filter ( String msg , Name otherUser , boolean outgoing ) { if ( ( otherUser != null ) && isMuted ( otherUser ) ) { if ( outgoing ) { _chatdir . displayFeedback ( null , "m.no_tell_mute" ) ; } return null ; } return msg ; } | documentation inherited from interface ChatFilter |
13,696 | protected void notifyObservers ( final Name username , final boolean muted ) { _observers . apply ( new ObserverList . ObserverOp < MuteObserver > ( ) { public boolean apply ( MuteObserver observer ) { observer . muteChanged ( username , muted ) ; return true ; } } ) ; } | Notify our observers of a change in the mutelist . |
13,697 | public void clearDispatcher ( InvocationMarshaller < ? > marsh ) { _omgr . requireEventThread ( ) ; if ( marsh == null ) { log . warning ( "Refusing to unregister null marshaller." , new Exception ( ) ) ; return ; } if ( _dispatchers . remove ( marsh . getInvocationCode ( ) ) == null ) { log . warning ( "Requested to remove unregistered marshaller?" , "marsh" , marsh , new Exception ( ) ) ; } } | Clears out a dispatcher registration . This should be called to free up resources when an invocation service is no longer going to be used . |
13,698 | public List < InvocationMarshaller < ? > > getBootstrapServices ( String [ ] bootGroups ) { List < InvocationMarshaller < ? > > services = Lists . newArrayList ( ) ; for ( String group : bootGroups ) { services . addAll ( _bootlists . get ( group ) ) ; } return services ; } | Constructs a list of all bootstrap services registered in any of the supplied groups . |
13,699 | public Class < ? > getDispatcherClass ( int invCode ) { Object dispatcher = _dispatchers . get ( invCode ) ; return ( dispatcher == null ) ? null : dispatcher . getClass ( ) ; } | Get the class that is being used to dispatch the specified invocation code for informational purposes . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.