idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
29,100
private void handleTmpView ( View v ) { Address new_coord = v . getCoord ( ) ; if ( new_coord != null && ! new_coord . equals ( coord ) && local_addr != null && local_addr . equals ( new_coord ) ) handleViewChange ( v ) ; }
an immediate change of view . See JGRP - 1452 .
29,101
private void integrate ( HashMap < String , Float > state ) { if ( state != null ) state . keySet ( ) . forEach ( key -> stocks . put ( key , state . get ( key ) ) ) ; }
default stack from JChannel
29,102
protected static void sanityCheck ( byte [ ] buf , int offset , int length ) { if ( buf == null ) throw new NullPointerException ( "buffer is null" ) ; if ( offset + length > buf . length ) throw new ArrayIndexOutOfBoundsException ( "length (" + length + ") + offset (" + offset + ") > buf.length (" + buf . length + ")" ) ; }
Verifies that length doesn t exceed a buffer s length
29,103
public void setCertificate ( ) throws KeyStoreException , IOException , NoSuchAlgorithmException , CertificateException , NoSuchPaddingException , InvalidKeyException , IllegalBlockSizeException , BadPaddingException , UnrecoverableEntryException { KeyStore store = KeyStore . getInstance ( this . keystore_type ) ; InputStream inputStream = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( this . keystore_path ) ; if ( inputStream == null ) inputStream = new FileInputStream ( this . keystore_path ) ; store . load ( inputStream , this . keystore_password ) ; this . cipher = Cipher . getInstance ( this . cipher_type ) ; this . certificate = ( X509Certificate ) store . getCertificate ( this . cert_alias ) ; log . debug ( "certificate = " + this . certificate . toString ( ) ) ; this . cipher . init ( Cipher . ENCRYPT_MODE , this . certificate ) ; this . encryptedToken = this . cipher . doFinal ( this . auth_value . getBytes ( ) ) ; KeyStore . PrivateKeyEntry privateKey = ( KeyStore . PrivateKeyEntry ) store . getEntry ( this . cert_alias , new KeyStore . PasswordProtection ( this . cert_password ) ) ; this . certPrivateKey = privateKey . getPrivateKey ( ) ; this . valueSet = true ; }
Used during setup to get the certification from the keystore and encrypt the auth_value with the private key
29,104
public static < T extends Header > T getHeader ( final Header [ ] hdrs , short id ) { if ( hdrs == null ) return null ; for ( Header hdr : hdrs ) { if ( hdr == null ) return null ; if ( hdr . getProtId ( ) == id ) return ( T ) hdr ; } return null ; }
Returns the header associated with an ID
29,105
public static Header [ ] putHeader ( final Header [ ] headers , short id , Header hdr , boolean replace_if_present ) { int i = 0 ; Header [ ] hdrs = headers ; boolean resized = false ; while ( i < hdrs . length ) { if ( hdrs [ i ] == null ) { hdrs [ i ] = hdr ; return resized ? hdrs : null ; } short hdr_id = hdrs [ i ] . getProtId ( ) ; if ( hdr_id == id ) { if ( replace_if_present || hdrs [ i ] == null ) hdrs [ i ] = hdr ; return resized ? hdrs : null ; } i ++ ; if ( i >= hdrs . length ) { hdrs = resize ( hdrs ) ; resized = true ; } } throw new IllegalStateException ( "unable to add element " + id + ", index=" + i ) ; }
Adds hdr at the next available slot . If none is available the headers array passed in will be copied and the copy returned
29,106
public static Header [ ] resize ( final Header [ ] headers ) { int new_capacity = headers . length + RESIZE_INCR ; Header [ ] new_hdrs = new Header [ new_capacity ] ; System . arraycopy ( headers , 0 , new_hdrs , 0 , headers . length ) ; return new_hdrs ; }
Increases the capacity of the array and copies the contents of the old into the new array
29,107
protected static String print ( BiConsumer < Integer , Integer > wait_strategy ) { if ( wait_strategy == null ) return null ; if ( wait_strategy == SPIN ) return "spin" ; else if ( wait_strategy == YIELD ) return "yield" ; else if ( wait_strategy == PARK ) return "park" ; else if ( wait_strategy == SPIN_PARK ) return "spin-park" ; else if ( wait_strategy == SPIN_YIELD ) return "spin-yield" ; else return wait_strategy . getClass ( ) . getSimpleName ( ) ; }
fast equivalent to %
29,108
public void leave ( Address mbr ) { if ( mbr == null ) { if ( log . isErrorEnabled ( ) ) log . error ( Util . getMessage ( "MemberSAddressIsNull" ) ) ; return ; } ViewHandler < Request > vh = gms . getViewHandler ( ) ; vh . add ( new Request ( Request . COORD_LEAVE , mbr ) ) ; long timeout = ( long ) ( Math . max ( gms . leave_timeout , gms . view_ack_collection_timeout ) * 1.5 ) ; vh . waitUntilComplete ( timeout ) ; }
The coordinator itself wants to leave the group
29,109
private Message unfragment ( Message msg , FragHeader hdr ) { Address sender = msg . getSrc ( ) ; FragmentationTable frag_table = fragment_list . get ( sender ) ; if ( frag_table == null ) { frag_table = new FragmentationTable ( sender ) ; try { fragment_list . add ( sender , frag_table ) ; } catch ( IllegalArgumentException x ) { frag_table = fragment_list . get ( sender ) ; } } num_received_frags ++ ; byte [ ] buf = frag_table . add ( hdr . id , hdr . frag_id , hdr . num_frags , msg . getBuffer ( ) ) ; if ( buf == null ) return null ; try { DataInput in = new ByteArrayDataInputStream ( buf ) ; Message assembled_msg = new Message ( false ) ; assembled_msg . readFrom ( in ) ; assembled_msg . setSrc ( sender ) ; if ( log . isTraceEnabled ( ) ) log . trace ( "assembled_msg is " + assembled_msg ) ; num_received_msgs ++ ; return assembled_msg ; } catch ( Exception e ) { log . error ( Util . getMessage ( "FailedUnfragmentingAMessage" ) , e ) ; return null ; } }
1 . Get all the fragment buffers 2 . When all are received - > Assemble them into one big buffer 3 . Read headers and byte buffer from big buffer 4 . Set headers and buffer in msg 5 . Pass msg up the stack
29,110
public boolean decrementIfEnoughCredits ( final Message msg , int credits , long timeout ) { lock . lock ( ) ; try { if ( queuing ) return addToQueue ( msg , credits ) ; if ( decrement ( credits ) ) return true ; queuing = true ; return addToQueue ( msg , credits ) ; } finally { lock . unlock ( ) ; } }
Decrements the sender s credits by the size of the message .
29,111
public static void add ( short magic , Class clazz ) { if ( magic < MIN_CUSTOM_MAGIC_NUMBER ) throw new IllegalArgumentException ( "magic ID (" + magic + ") must be >= " + MIN_CUSTOM_MAGIC_NUMBER ) ; if ( magicMapUser . containsKey ( magic ) || classMap . containsKey ( clazz ) ) alreadyInMagicMap ( magic , clazz . getName ( ) ) ; Object inst = null ; try { inst = clazz . getDeclaredConstructor ( ) . newInstance ( ) ; } catch ( Exception e ) { throw new IllegalStateException ( "failed creating instance " + clazz , e ) ; } Object val = clazz ; if ( Header . class . isAssignableFrom ( clazz ) ) { checkSameId ( ( Header ) inst , magic ) ; val = ( ( Header ) inst ) . create ( ) ; } if ( Constructable . class . isAssignableFrom ( clazz ) ) { val = ( ( Constructable ) inst ) . create ( ) ; inst = ( ( Supplier < ? > ) val ) . get ( ) ; if ( ! inst . getClass ( ) . equals ( clazz ) ) throw new IllegalStateException ( String . format ( "%s.create() returned the wrong class: %s\n" , clazz . getSimpleName ( ) , inst . getClass ( ) . getSimpleName ( ) ) ) ; } magicMapUser . put ( magic , val ) ; classMap . put ( clazz , magic ) ; }
Method to register a user - defined header with jg - magic - map at runtime
29,112
public static Class get ( String clazzname , ClassLoader loader ) throws ClassNotFoundException { return Util . loadClass ( clazzname , loader != null ? loader : ClassConfigurator . class . getClassLoader ( ) ) ; }
Loads and returns the class from the class name
29,113
public static short getMagicNumber ( Class clazz ) { Short i = classMap . get ( clazz ) ; if ( i == null ) return - 1 ; else return i ; }
Returns the magic number for the class .
29,114
public void merge ( Map < Address , View > views ) { if ( views == null || views . isEmpty ( ) ) { log . warn ( "the views passed with the MERGE event were empty (or null); ignoring MERGE event" ) ; return ; } if ( View . sameViews ( views . values ( ) ) ) { log . debug ( "MERGE event is ignored because of identical views: %s" , Util . printListWithDelimiter ( views . values ( ) , ", " ) ) ; return ; } if ( isMergeInProgress ( ) ) { log . trace ( "%s: merge is already running (merge_id=%s)" , gms . local_addr , merge_id ) ; return ; } Address merge_leader = determineMergeLeader ( views ) ; if ( merge_leader == null ) return ; if ( merge_leader . equals ( gms . local_addr ) ) { log . debug ( "%s: I will be the merge leader. Starting the merge task. Views: %s" , gms . local_addr , views ) ; merge_task . start ( views ) ; } else log . trace ( "%s: I'm not the merge leader, waiting for merge leader (%s) to start merge" , gms . local_addr , merge_leader ) ; }
Invoked upon receiving a MERGE event from the MERGE layer . Starts the merge protocol . See description of protocol in DESIGN .
29,115
protected Address determineMergeLeader ( Map < Address , View > views ) { Collection < Address > coords = Util . determineActualMergeCoords ( views ) ; if ( coords . isEmpty ( ) ) coords = Util . determineMergeCoords ( views ) ; if ( coords . isEmpty ( ) ) { log . error ( "%s: unable to determine merge leader from %s; not starting a merge" , gms . local_addr , views ) ; return null ; } return new Membership ( coords ) . sort ( ) . elementAt ( 0 ) ; }
Returns the address of the merge leader
29,116
protected void sendMergeResponse ( Address sender , View view , Digest digest , MergeId merge_id ) { Message msg = new Message ( sender ) . setBuffer ( GMS . marshal ( view , digest ) ) . setFlag ( Message . Flag . OOB , Message . Flag . INTERNAL ) . putHeader ( gms . getId ( ) , new GMS . GmsHeader ( GMS . GmsHeader . MERGE_RSP ) . mergeId ( merge_id ) ) ; gms . getDownProtocol ( ) . down ( msg ) ; }
Send back a response containing view and digest to sender
29,117
protected void sendMergeView ( Collection < Address > coords , MergeData combined_merge_data , MergeId merge_id ) { if ( coords == null || coords . isEmpty ( ) || combined_merge_data == null ) return ; View view = combined_merge_data . view ; Digest digest = combined_merge_data . digest ; if ( view == null || digest == null ) { log . error ( Util . getMessage ( "ViewOrDigestIsNullCannotSendConsolidatedMergeView/Digest" ) ) ; return ; } int size = 0 ; if ( gms . flushProtocolInStack ) { gms . merge_ack_collector . reset ( coords ) ; size = gms . merge_ack_collector . size ( ) ; } Event install_merge_view_evt = new Event ( Event . INSTALL_MERGE_VIEW , view ) ; gms . getUpProtocol ( ) . up ( install_merge_view_evt ) ; gms . getDownProtocol ( ) . down ( install_merge_view_evt ) ; long start = System . currentTimeMillis ( ) ; for ( Address coord : coords ) { Message msg = new Message ( coord ) . setBuffer ( GMS . marshal ( view , digest ) ) . putHeader ( gms . getId ( ) , new GMS . GmsHeader ( GMS . GmsHeader . INSTALL_MERGE_VIEW ) . mergeId ( merge_id ) ) ; gms . getDownProtocol ( ) . down ( msg ) ; } if ( gms . flushProtocolInStack ) { try { gms . merge_ack_collector . waitForAllAcks ( gms . view_ack_collection_timeout ) ; log . trace ( "%s: received all ACKs (%d) for merge view %s in %d ms" , gms . local_addr , size , view , ( System . currentTimeMillis ( ) - start ) ) ; } catch ( TimeoutException e ) { log . warn ( "%s: failed to collect all ACKs (%d) for merge view %s after %d ms, missing ACKs from %s" , gms . local_addr , size , view , gms . view_ack_collection_timeout , gms . merge_ack_collector . printMissing ( ) ) ; } } }
Sends the new view and digest to all subgroup coordinators . Each coord will in turn broadcast the new view and digest to all the members of its subgroup
29,118
protected void fixDigests ( ) { Digest digest = fetchDigestsFromAllMembersInSubPartition ( gms . view , null ) ; Message msg = new Message ( ) . putHeader ( gms . getId ( ) , new GMS . GmsHeader ( GMS . GmsHeader . INSTALL_DIGEST ) ) . setBuffer ( GMS . marshal ( null , digest ) ) ; gms . getDownProtocol ( ) . down ( msg ) ; }
Fetches the digests from all members and installs them again . Used only for diagnosis and support ; don t use this otherwise !
29,119
public boolean allSet ( ) { for ( int i = 0 ; i < seqnos . length ; i += 2 ) if ( seqnos [ i ] == - 1 ) return false ; return true ; }
Returns true if all members have a corresponding seqno > = 0 else false
29,120
public Address [ ] getNonSetMembers ( ) { Address [ ] retval = new Address [ countNonSetMembers ( ) ] ; if ( retval . length == 0 ) return retval ; int index = 0 ; for ( int i = 0 ; i < members . length ; i ++ ) if ( seqnos [ i * 2 ] == - 1 ) retval [ index ++ ] = members [ i ] ; return retval ; }
Returns an array of members whose seqno is not set . Returns an empty array if all are set .
29,121
public long add ( T element ) { lock . lock ( ) ; try { long next = high + 1 ; if ( next - low > capacity ( ) ) _grow ( next - low ) ; int high_index = index ( high ) ; buffer [ high_index ] = element ; return high ++ ; } finally { lock . unlock ( ) ; } }
Adds a new element and returns the sequence number at which it was inserted . Advances the high pointer and grows the buffer if needed .
29,122
public T remove ( long seqno ) { lock . lock ( ) ; try { if ( seqno < low || seqno > high ) return null ; int index = index ( seqno ) ; T retval = buffer [ index ] ; if ( retval != null && removes_till_compaction > 0 ) num_removes ++ ; buffer [ index ] = null ; if ( seqno == low ) advanceLow ( ) ; if ( removes_till_compaction > 0 && num_removes >= removes_till_compaction ) { _compact ( ) ; num_removes = 0 ; } return retval ; } finally { lock . unlock ( ) ; } }
Removes the element at the index matching seqno . If seqno == low tries to advance low until a non - null element is encountered up to high
29,123
public RequestTable < T > grow ( int new_capacity ) { lock . lock ( ) ; try { _grow ( new_capacity ) ; return this ; } finally { lock . unlock ( ) ; } }
Grows the array to at least new_capacity . This method is mainly used for testing and is not typically called directly but indirectly when adding elements and the underlying array has no space left .
29,124
@ GuardedBy ( "lock" ) protected boolean _compact ( ) { int new_cap = buffer . length >> 1 ; boolean compactable = this . buffer . length > 0 && high - low <= new_cap ; if ( ! compactable ) return false ; _copy ( new_cap ) ; return true ; }
Shrinks the array to half of its current size if the current number of elements fit into half of the capacity .
29,125
protected void _copy ( int new_cap ) { T [ ] new_buf = ( T [ ] ) new Object [ new_cap ] ; int new_len = new_buf . length ; int old_len = this . buffer . length ; for ( long i = low , num_iterations = 0 ; i < high && num_iterations < old_len ; i ++ , num_iterations ++ ) { int old_index = index ( i , old_len ) ; if ( this . buffer [ old_index ] != null ) { int new_index = index ( i , new_len ) ; new_buf [ new_index ] = this . buffer [ old_index ] ; } } this . buffer = new_buf ; }
Copies elements from old into new array
29,126
public T remove ( ) { lock . lock ( ) ; try { if ( queue . isEmpty ( ) ) return null ; El < T > el = queue . poll ( ) ; count -= el . size ; not_full . signalAll ( ) ; return el . el ; } finally { lock . unlock ( ) ; } }
Removes and returns the first element or null if the queue is empty
29,127
public void addNewMessageToSend ( MessageID messageID , Collection < Address > destinations , long initialSequenceNumber , boolean deliverToMyself ) { MessageInfo messageInfo = new MessageInfo ( destinations , initialSequenceNumber , deliverToMyself ) ; if ( deliverToMyself ) { messageInfo . setProposeReceived ( messageID . getAddress ( ) ) ; } sentMessages . put ( messageID , messageInfo ) ; }
Add a new message sent
29,128
public long addPropose ( MessageID messageID , Address from , long sequenceNumber ) { MessageInfo messageInfo = sentMessages . get ( messageID ) ; if ( messageInfo != null && messageInfo . addPropose ( from , sequenceNumber ) ) { return messageInfo . getAndMarkFinalSent ( ) ; } return NOT_READY ; }
Add a propose from a member in destination set
29,129
public boolean markSent ( MessageID messageID ) { MessageInfo messageInfo = sentMessages . remove ( messageID ) ; return messageInfo != null && messageInfo . toSelfDeliver ; }
Mark the message as sent
29,130
public Set < Address > getDestination ( MessageID messageID ) { MessageInfo messageInfo = sentMessages . get ( messageID ) ; Set < Address > destination ; if ( messageInfo != null ) { destination = new HashSet < > ( messageInfo . destinations ) ; } else { destination = Collections . emptySet ( ) ; } return destination ; }
obtains the destination set of a message
29,131
public < T extends Average > T merge ( T other ) { if ( Util . productGreaterThan ( count , ( long ) Math . ceil ( avg ) , Long . MAX_VALUE ) || Util . productGreaterThan ( other . count ( ) , ( long ) Math . ceil ( other . average ( ) ) , Long . MAX_VALUE ) ) { avg = avg + other . average ( ) / 2.0 ; } else { long total_count = count + other . count ( ) ; avg = ( count * avg + other . count ( ) * other . average ( ) ) / total_count ; count = total_count / 2 ; } return ( T ) this ; }
Merges this average with another one
29,132
public Collection < Range > getBits ( boolean value ) { int index = 0 ; int start_range = 0 , end_range = 0 ; int size = ( int ) ( ( high - low ) + 1 ) ; final Collection < Range > retval = new ArrayList < > ( size ) ; while ( index < size ) { start_range = value ? bits . nextSetBit ( index ) : bits . nextClearBit ( index ) ; if ( start_range < 0 || start_range >= size ) break ; end_range = value ? bits . nextClearBit ( start_range ) : bits . nextSetBit ( start_range ) ; if ( end_range < 0 || end_range >= size ) { retval . add ( new Range ( start_range + low , size - 1 + low ) ) ; break ; } retval . add ( new Range ( start_range + low , end_range - 1 + low ) ) ; index = end_range ; } return retval ; }
Returns ranges of all bit set to value
29,133
public void installRule ( String name , long interval , Rule rule ) { rule . supervisor ( this ) . log ( log ) . init ( ) ; Future < ? > future = timer . scheduleAtFixedRate ( rule , interval , interval , TimeUnit . MILLISECONDS ) ; Tuple < Rule , Future < ? > > existing = rules . put ( name != null ? name : rule . name ( ) , new Tuple < > ( rule , future ) ) ; if ( existing != null ) existing . getVal2 ( ) . cancel ( true ) ; }
Installs a new rule
29,134
protected void handleStateRsp ( final Digest digest , Address sender , byte [ ] state ) { try { if ( isDigestNeeded ( ) ) { punchHoleFor ( sender ) ; closeBarrierAndSuspendStable ( ) ; if ( digest != null ) down_prot . down ( new Event ( Event . OVERWRITE_DIGEST , digest ) ) ; } waiting_for_state_response = false ; stop = System . currentTimeMillis ( ) ; log . debug ( "%s: received state, size=%s, time=%d milliseconds" , local_addr , ( state == null ? "0" : Util . printBytes ( state . length ) ) , stop - start ) ; StateTransferResult result = new StateTransferResult ( state ) ; up_prot . up ( new Event ( Event . GET_STATE_OK , result ) ) ; down_prot . down ( new Event ( Event . GET_VIEW_FROM_COORD ) ) ; } catch ( Throwable t ) { handleException ( t ) ; } finally { if ( isDigestNeeded ( ) ) { closeHoleFor ( sender ) ; openBarrierAndResumeStable ( ) ; } } }
Set the digest and the send the state up to the application
29,135
protected int advanceWriteIndex ( ) { int num = 0 , start = write_index ; for ( ; ; ) { if ( buf [ start ] == null ) break ; num ++ ; start = index ( start + 1 ) ; if ( start == tmp_write_index . get ( ) ) break ; } write_index = start ; return num ; }
Advance write_index up to tmp_write_index as long as no null msg is found
29,136
void drawEmptyBoard ( Graphics g ) { int x = x_offset , y = y_offset ; Color old_col = g . getColor ( ) ; g . setFont ( def_font2 ) ; old_col = g . getColor ( ) ; g . setColor ( checksum_col ) ; g . drawString ( ( "Checksum: " + checksum ) , x_offset + field_size , y_offset - 20 ) ; g . setFont ( def_font ) ; g . setColor ( old_col ) ; for ( int i = 0 ; i < num_fields ; i ++ ) { for ( int j = 0 ; j < num_fields ; j ++ ) { g . drawRect ( x , y , field_size , field_size ) ; x += field_size ; } g . drawString ( ( String . valueOf ( ( num_fields - i - 1 ) ) ) , x + 20 , y + field_size / 2 ) ; y += field_size ; x = x_offset ; } for ( int i = 0 ; i < num_fields ; i ++ ) { g . drawString ( ( String . valueOf ( i ) ) , x_offset + i * field_size + field_size / 2 , y + 30 ) ; } }
Draws the empty board no pieces on it yet just grid lines
29,137
private void onSuspend ( final List < Address > members ) { Message msg = null ; Collection < Address > participantsInFlush = null ; synchronized ( sharedLock ) { flushCoordinator = localAddress ; participantsInFlush = members ; participantsInFlush . retainAll ( currentView . getMembers ( ) ) ; flushMembers . clear ( ) ; flushMembers . addAll ( participantsInFlush ) ; flushMembers . removeAll ( suspected ) ; msg = new Message ( null ) . src ( localAddress ) . setBuffer ( marshal ( participantsInFlush , null ) ) . putHeader ( this . id , new FlushHeader ( FlushHeader . START_FLUSH , currentViewId ( ) ) ) ; } if ( participantsInFlush . isEmpty ( ) ) { flush_promise . setResult ( SUCCESS_START_FLUSH ) ; } else { down_prot . down ( msg ) ; if ( log . isDebugEnabled ( ) ) log . debug ( localAddress + ": flush coordinator " + " is starting FLUSH with participants " + participantsInFlush ) ; } }
Starts the flush protocol
29,138
protected static Digest maxSeqnos ( final View view , List < Digest > digests ) { if ( view == null || digests == null ) return null ; MutableDigest digest = new MutableDigest ( view . getMembersRaw ( ) ) ; digests . forEach ( digest :: merge ) ; return digest ; }
Returns a digest which contains for all members of view the highest delivered and received seqno of all digests
29,139
public List < Address > getNewMembership ( final Collection < Collection < Address > > subviews ) { ArrayList < Collection < Address > > aSubviews = new ArrayList < > ( subviews ) ; int sLargest = 0 ; int iLargest = 0 ; for ( int i = 0 ; i < aSubviews . size ( ) ; i ++ ) { int size = aSubviews . get ( i ) . size ( ) ; if ( size > sLargest ) { sLargest = size ; iLargest = i ; } } Membership mbrs = new Membership ( aSubviews . get ( iLargest ) ) ; for ( int i = 0 ; i < aSubviews . size ( ) ; i ++ ) if ( i != iLargest ) mbrs . add ( aSubviews . get ( i ) ) ; return mbrs . getMembers ( ) ; }
Called when a merge happened . The largest subview wins .
29,140
protected void sendLocalAddress ( Address local_addr ) throws Exception { try { out . write ( cookie , 0 , cookie . length ) ; out . writeShort ( Version . version ) ; out . writeShort ( local_addr . serializedSize ( ) ) ; local_addr . writeTo ( out ) ; out . flush ( ) ; updateLastAccessed ( ) ; } catch ( Exception ex ) { server . socket_factory . close ( this . sock ) ; connected = false ; throw ex ; } }
Send the cookie first then the our port number . If the cookie doesn t match the receiver s cookie the receiver will reject the connection and close it .
29,141
protected Address readPeerAddress ( Socket client_sock ) throws Exception { int timeout = client_sock . getSoTimeout ( ) ; client_sock . setSoTimeout ( server . peerAddressReadTimeout ( ) ) ; try { byte [ ] input_cookie = new byte [ cookie . length ] ; in . readFully ( input_cookie , 0 , input_cookie . length ) ; if ( ! Arrays . equals ( cookie , input_cookie ) ) throw new SocketException ( String . format ( "%s: BaseServer.TcpConnection.readPeerAddress(): cookie sent by " + "%s:%d does not match own cookie; terminating connection" , server . localAddress ( ) , client_sock . getInetAddress ( ) , client_sock . getPort ( ) ) ) ; short version = in . readShort ( ) ; if ( ! Version . isBinaryCompatible ( version ) ) throw new IOException ( "packet from " + client_sock . getInetAddress ( ) + ":" + client_sock . getPort ( ) + " has different version (" + Version . print ( version ) + ") from ours (" + Version . printVersion ( ) + "); discarding it" ) ; in . readShort ( ) ; Address client_peer_addr = new IpAddress ( ) ; client_peer_addr . readFrom ( in ) ; updateLastAccessed ( ) ; return client_peer_addr ; } finally { client_sock . setSoTimeout ( timeout ) ; } }
Reads the peer s address . First a cookie has to be sent which has to match my own cookie otherwise the connection will be refused
29,142
public static void unregister ( MBeanServer server , String object_name ) throws Exception { Set < ObjectName > mbeans = server . queryNames ( new ObjectName ( object_name ) , null ) ; if ( mbeans != null ) for ( ObjectName name : mbeans ) server . unregisterMBean ( name ) ; }
Unregisters object_name and everything under it
29,143
public void send ( Address dst , byte [ ] buf , int offset , int length ) throws Exception { ch . send ( dst , buf , offset , length ) ; }
Sends a message to a destination .
29,144
public Object down ( Event evt ) { if ( evt . type ( ) == 1 ) return ch . down ( ( Message ) evt . getArg ( ) ) ; return ch . down ( evt ) ; }
Enables access to event mechanism of a channel and is normally not used by clients directly .
29,145
public Value putIfAbsent ( T key , long expiry_time ) { if ( key == null ) key = NULL_KEY ; Value val = map . get ( key ) ; if ( val == null ) { val = new Value ( ) ; Value existing = map . putIfAbsent ( key , val ) ; if ( existing == null ) return val ; val = existing ; } if ( val . update ( ) . age ( ) > expiry_time ) { map . remove ( key ) ; map . putIfAbsent ( key , new Value ( ) ) ; return val ; } return null ; }
Adds a new key to the hashmap or updates the Value associated with the existing key if present . If expiry_time is greater than the age of the Value the key will be removed .
29,146
public int size ( ) { int count = 0 ; for ( Value val : map . values ( ) ) count += val . count ( ) ; return count ; }
Returns the total count of all values
29,147
public void log ( Level level , T key , long timeout , Object ... args ) { SuppressCache . Value val = cache . putIfAbsent ( key , timeout ) ; if ( val == null ) return ; String message = val . count ( ) == 1 ? String . format ( message_format , args ) : String . format ( message_format , args ) + " " + String . format ( suppress_format , val . count ( ) , key , val . age ( ) ) ; switch ( level ) { case error : log . error ( message ) ; break ; case warn : log . warn ( message ) ; break ; case trace : log . trace ( message ) ; break ; } }
Logs a message from a given member if is hasn t been logged for timeout ms
29,148
public void enableReaping ( long interval ) { if ( task != null ) task . cancel ( false ) ; task = timer . scheduleWithFixedDelay ( new Reaper ( ) , 0 , interval , TimeUnit . MILLISECONDS ) ; }
Runs the reaper every interval ms evicts expired items
29,149
public int add ( final Message msg , boolean resize ) { if ( msg == null ) return 0 ; if ( index >= messages . length ) { if ( ! resize ) return 0 ; resize ( ) ; } messages [ index ++ ] = msg ; return 1 ; }
Adds a message to the table
29,150
public int add ( final MessageBatch batch , boolean resize ) { if ( batch == null ) return 0 ; if ( this == batch ) throw new IllegalArgumentException ( "cannot add batch to itself" ) ; int batch_size = batch . size ( ) ; if ( index + batch_size >= messages . length && resize ) resize ( messages . length + batch_size + 1 ) ; int cnt = 0 ; for ( Message msg : batch ) { if ( index >= messages . length ) return cnt ; messages [ index ++ ] = msg ; cnt ++ ; } return cnt ; }
Adds another batch to this one
29,151
public MessageBatch replace ( Message existing_msg , Message new_msg ) { if ( existing_msg == null ) return this ; for ( int i = 0 ; i < index ; i ++ ) { if ( messages [ i ] != null && messages [ i ] == existing_msg ) { messages [ i ] = new_msg ; break ; } } return this ; }
Replaces a message in the batch with another one
29,152
public MessageBatch replace ( Predicate < Message > filter , Message replacement , boolean match_all ) { replaceIf ( filter , replacement , match_all ) ; return this ; }
Replaces all messages which match a given filter with a replacement message
29,153
public int replaceIf ( Predicate < Message > filter , Message replacement , boolean match_all ) { if ( filter == null ) return 0 ; int matched = 0 ; for ( int i = 0 ; i < index ; i ++ ) { if ( filter . test ( messages [ i ] ) ) { messages [ i ] = replacement ; matched ++ ; if ( ! match_all ) break ; } } return matched ; }
Replaces all messages that match a given filter with a replacement message
29,154
public int transferFrom ( MessageBatch other , boolean clear ) { if ( other == null || this == other ) return 0 ; int capacity = messages . length , other_size = other . size ( ) ; if ( other_size == 0 ) return 0 ; if ( capacity < other_size ) messages = new Message [ other_size ] ; System . arraycopy ( other . messages , 0 , this . messages , 0 , other_size ) ; if ( this . index > other_size ) for ( int i = other_size ; i < this . index ; i ++ ) messages [ i ] = null ; this . index = other_size ; if ( clear ) other . clear ( ) ; return other_size ; }
Transfers messages from other to this batch . Optionally clears the other batch after the transfer
29,155
public Collection < Message > getMatchingMessages ( final short id , boolean remove ) { return map ( ( msg , batch ) -> { if ( msg != null && msg . getHeader ( id ) != null ) { if ( remove ) batch . remove ( msg ) ; return msg ; } return null ; } ) ; }
Removes and returns all messages which have a header with ID == id
29,156
public < T > Collection < T > map ( BiFunction < Message , MessageBatch , T > visitor ) { Collection < T > retval = null ; for ( int i = 0 ; i < index ; i ++ ) { try { T result = visitor . apply ( messages [ i ] , this ) ; if ( result != null ) { if ( retval == null ) retval = new ArrayList < > ( ) ; retval . add ( result ) ; } } catch ( Throwable t ) { } } return retval ; }
Applies a function to all messages and returns a list of the function results
29,157
public int size ( ) { int retval = 0 ; for ( int i = 0 ; i < index ; i ++ ) if ( messages [ i ] != null ) retval ++ ; return retval ; }
Returns the number of non - null messages
29,158
protected boolean shouldDropUpMessage ( @ SuppressWarnings ( "UnusedParameters" ) Message msg , Address sender ) { if ( discard_all && ! sender . equals ( localAddress ( ) ) ) return true ; if ( ignoredMembers . contains ( sender ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( localAddress + ": dropping message from " + sender ) ; num_up ++ ; return true ; } if ( up > 0 ) { double r = Math . random ( ) ; if ( r < up ) { if ( excludeItself && sender . equals ( localAddress ( ) ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( "excluding myself" ) ; } else { if ( log . isTraceEnabled ( ) ) log . trace ( localAddress + ": dropping message from " + sender ) ; num_up ++ ; return true ; } } } return false ; }
Checks if a message should be passed up or not
29,159
protected void drain ( ) { Message msg ; while ( ( msg = queue . poll ( ) ) != null ) addAndSendIfSizeExceeded ( msg ) ; _sendBundledMessages ( ) ; }
Takes all messages from the queue adds them to the hashmap and then sends all bundled messages
29,160
public E buildTextComponent ( ) { final E textComponent = createTextComponent ( ) ; textComponent . setRequired ( required ) ; textComponent . setImmediate ( immediate ) ; textComponent . setReadOnly ( readOnly ) ; textComponent . setEnabled ( enabled ) ; if ( ! StringUtils . isEmpty ( caption ) ) { textComponent . setCaption ( caption ) ; } if ( ! StringUtils . isEmpty ( style ) ) { textComponent . setStyleName ( style ) ; } if ( ! StringUtils . isEmpty ( styleName ) ) { textComponent . addStyleName ( styleName ) ; } if ( ! StringUtils . isEmpty ( prompt ) ) { textComponent . setInputPrompt ( prompt ) ; } if ( maxLengthAllowed > 0 ) { textComponent . setMaxLength ( maxLengthAllowed ) ; } if ( ! StringUtils . isEmpty ( id ) ) { textComponent . setId ( id ) ; } if ( ! validators . isEmpty ( ) ) { validators . forEach ( textComponent :: addValidator ) ; } textComponent . setNullRepresentation ( "" ) ; return textComponent ; }
Build a textfield
29,161
public void populateTableByDistributionSet ( final DistributionSet distributionSet ) { removeAllItems ( ) ; if ( distributionSet == null ) { return ; } final Container dataSource = getContainerDataSource ( ) ; final List < TargetFilterQuery > filters = distributionSet . getAutoAssignFilters ( ) ; filters . forEach ( query -> { final Object itemId = dataSource . addItem ( ) ; final Item item = dataSource . getItem ( itemId ) ; item . getItemProperty ( TFQ_NAME ) . setValue ( query . getName ( ) ) ; item . getItemProperty ( TFQ_QUERY ) . setValue ( query . getQuery ( ) ) ; } ) ; }
Populate software module metadata .
29,162
private void createRequiredComponents ( ) { distNameTextField = createTextField ( "textfield.name" , UIComponentIdProvider . DIST_ADD_NAME , DistributionSet . NAME_MAX_SIZE ) ; distVersionTextField = createTextField ( "textfield.version" , UIComponentIdProvider . DIST_ADD_VERSION , DistributionSet . VERSION_MAX_SIZE ) ; distsetTypeNameComboBox = SPUIComponentProvider . getComboBox ( i18n . getMessage ( "label.combobox.type" ) , "" , null , "" , false , "" , i18n . getMessage ( "label.combobox.type" ) ) ; distsetTypeNameComboBox . setImmediate ( true ) ; distsetTypeNameComboBox . setNullSelectionAllowed ( false ) ; distsetTypeNameComboBox . setId ( UIComponentIdProvider . DIST_ADD_DISTSETTYPE ) ; descTextArea = new TextAreaBuilder ( DistributionSet . DESCRIPTION_MAX_SIZE ) . caption ( i18n . getMessage ( "textfield.description" ) ) . style ( "text-area-style" ) . id ( UIComponentIdProvider . DIST_ADD_DESC ) . buildTextComponent ( ) ; reqMigStepCheckbox = SPUIComponentProvider . getCheckBox ( i18n . getMessage ( "checkbox.dist.required.migration.step" ) , "dist-checkbox-style" , null , false , "" ) ; reqMigStepCheckbox . addStyleName ( ValoTheme . CHECKBOX_SMALL ) ; reqMigStepCheckbox . setId ( UIComponentIdProvider . DIST_ADD_MIGRATION_CHECK ) ; }
Create required UI components .
29,163
private static LazyQueryContainer getDistSetTypeLazyQueryContainer ( ) { final BeanQueryFactory < DistributionSetTypeBeanQuery > dtQF = new BeanQueryFactory < > ( DistributionSetTypeBeanQuery . class ) ; dtQF . setQueryConfiguration ( Collections . emptyMap ( ) ) ; final LazyQueryContainer disttypeContainer = new LazyQueryContainer ( new LazyQueryDefinition ( true , SPUIDefinitions . DIST_TYPE_SIZE , SPUILabelDefinitions . VAR_ID ) , dtQF ) ; disttypeContainer . addContainerProperty ( SPUILabelDefinitions . VAR_NAME , String . class , "" , true , true ) ; return disttypeContainer ; }
Get the LazyQueryContainer instance for DistributionSetTypes .
29,164
public void resetComponents ( ) { distNameTextField . clear ( ) ; distNameTextField . removeStyleName ( "v-textfield-error" ) ; distVersionTextField . clear ( ) ; distVersionTextField . removeStyleName ( SPUIStyleDefinitions . SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT ) ; distsetTypeNameComboBox . removeStyleName ( SPUIStyleDefinitions . SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT ) ; distsetTypeNameComboBox . clear ( ) ; distsetTypeNameComboBox . setEnabled ( true ) ; descTextArea . clear ( ) ; reqMigStepCheckbox . clear ( ) ; }
clear all the fields .
29,165
private CommonDialogWindow getWindow ( final Long editDistId ) { final SaveDialogCloseListener saveDialogCloseListener ; String caption ; resetComponents ( ) ; populateDistSetTypeNameCombo ( ) ; if ( editDistId == null ) { saveDialogCloseListener = new CreateOnCloseDialogListener ( ) ; caption = i18n . getMessage ( "caption.create.new" , i18n . getMessage ( "caption.distribution" ) ) ; } else { saveDialogCloseListener = new UpdateOnCloseDialogListener ( editDistId ) ; caption = i18n . getMessage ( "caption.update" , i18n . getMessage ( "caption.distribution" ) ) ; populateValuesOfDistribution ( editDistId ) ; } return new WindowBuilder ( SPUIDefinitions . CREATE_UPDATE_WINDOW ) . caption ( caption ) . content ( this ) . layout ( formLayout ) . i18n ( i18n ) . saveDialogCloseListener ( saveDialogCloseListener ) . buildCommonDialogWindow ( ) ; }
Internal method to create a window to create or update a DistributionSet .
29,166
private void populateDistSetTypeNameCombo ( ) { distsetTypeNameComboBox . setContainerDataSource ( getDistSetTypeLazyQueryContainer ( ) ) ; distsetTypeNameComboBox . setItemCaptionPropertyId ( SPUILabelDefinitions . VAR_NAME ) ; distsetTypeNameComboBox . setValue ( getDefaultDistributionSetType ( ) . getId ( ) ) ; }
Populate DistributionSet Type name combo .
29,167
private void createMaintenanceScheduleControl ( ) { schedule = new TextFieldBuilder ( Action . MAINTENANCE_WINDOW_SCHEDULE_LENGTH ) . id ( UIComponentIdProvider . MAINTENANCE_WINDOW_SCHEDULE_ID ) . caption ( i18n . getMessage ( "caption.maintenancewindow.schedule" ) ) . validator ( new CronValidator ( ) ) . prompt ( "0 0 3 ? * 6" ) . required ( true , i18n ) . buildTextComponent ( ) ; schedule . addTextChangeListener ( new CronTranslationListener ( ) ) ; }
Text field to specify the schedule .
29,168
private void createMaintenanceDurationControl ( ) { duration = new TextFieldBuilder ( Action . MAINTENANCE_WINDOW_DURATION_LENGTH ) . id ( UIComponentIdProvider . MAINTENANCE_WINDOW_DURATION_ID ) . caption ( i18n . getMessage ( "caption.maintenancewindow.duration" ) ) . validator ( new DurationValidator ( ) ) . prompt ( "hh:mm:ss" ) . required ( true , i18n ) . buildTextComponent ( ) ; }
Text field to specify the duration .
29,169
private void createMaintenanceTimeZoneControl ( ) { timeZone = new ComboBox ( ) ; timeZone . setId ( UIComponentIdProvider . MAINTENANCE_WINDOW_TIME_ZONE_ID ) ; timeZone . setCaption ( i18n . getMessage ( "caption.maintenancewindow.timezone" ) ) ; timeZone . addItems ( getAllTimeZones ( ) ) ; timeZone . setValue ( getClientTimeZone ( ) ) ; timeZone . addStyleName ( ValoTheme . COMBOBOX_SMALL ) ; timeZone . setTextInputAllowed ( false ) ; timeZone . setNullSelectionAllowed ( false ) ; }
Combo box to pick the time zone offset .
29,170
private static List < String > getAllTimeZones ( ) { final List < String > lst = ZoneId . getAvailableZoneIds ( ) . stream ( ) . map ( id -> ZonedDateTime . now ( ZoneId . of ( id ) ) . getOffset ( ) . getId ( ) . replace ( "Z" , "+00:00" ) ) . distinct ( ) . collect ( Collectors . toList ( ) ) ; lst . sort ( null ) ; return lst ; }
Get list of all time zone offsets supported .
29,171
private static String getClientTimeZone ( ) { return ZonedDateTime . now ( SPDateTimeUtil . getTimeZoneId ( SPDateTimeUtil . getBrowserTimeZone ( ) ) ) . getOffset ( ) . getId ( ) . replaceAll ( "Z" , "+00:00" ) ; }
Get time zone of the browser client to be used as default .
29,172
private void createMaintenanceScheduleTranslatorControl ( ) { scheduleTranslator = new LabelBuilder ( ) . id ( UIComponentIdProvider . MAINTENANCE_WINDOW_SCHEDULE_TRANSLATOR_ID ) . name ( i18n . getMessage ( CRON_VALIDATION_ERROR ) ) . buildLabel ( ) ; scheduleTranslator . addStyleName ( ValoTheme . LABEL_TINY ) ; }
Label to translate the cron schedule to human readable format .
29,173
public void clearAllControls ( ) { schedule . setValue ( "" ) ; duration . setValue ( "" ) ; timeZone . setValue ( getClientTimeZone ( ) ) ; scheduleTranslator . setValue ( i18n . getMessage ( CRON_VALIDATION_ERROR ) ) ; }
Set all the controls to their default values .
29,174
public void clear ( ) { queryTextField . clear ( ) ; validationIcon . setValue ( FontAwesome . CHECK_CIRCLE . getHtml ( ) ) ; validationIcon . setStyleName ( "hide-status-label" ) ; }
Clears the textfield and resets the validation icon .
29,175
public void showValidationSuccesIcon ( final String text ) { validationIcon . setValue ( FontAwesome . CHECK_CIRCLE . getHtml ( ) ) ; validationIcon . setStyleName ( SPUIStyleDefinitions . SUCCESS_ICON ) ; filterManagementUIState . setFilterQueryValue ( text ) ; filterManagementUIState . setIsFilterByInvalidFilterQuery ( Boolean . FALSE ) ; }
Shows the validation success icon in the textfield
29,176
public void showValidationFailureIcon ( final String validationMessage ) { validationIcon . setValue ( FontAwesome . TIMES_CIRCLE . getHtml ( ) ) ; validationIcon . setStyleName ( SPUIStyleDefinitions . ERROR_ICON ) ; validationIcon . setDescription ( validationMessage ) ; filterManagementUIState . setFilterQueryValue ( null ) ; filterManagementUIState . setIsFilterByInvalidFilterQuery ( Boolean . TRUE ) ; }
Shows the validation error icon in the textfield
29,177
public void showValidationInProgress ( ) { validationIcon . setValue ( null ) ; validationIcon . addStyleName ( "show-status-label" ) ; validationIcon . setStyleName ( SPUIStyleDefinitions . TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE ) ; }
Sets the spinner as progress indicator .
29,178
@ ConditionalOnProperty ( prefix = "hawkbit.server.security.dos.filter" , name = "enabled" , matchIfMissing = true ) public FilterRegistrationBean < DosFilter > dosSystemFilter ( final HawkbitSecurityProperties securityProperties ) { final FilterRegistrationBean < DosFilter > filterRegBean = dosFilter ( Collections . emptyList ( ) , securityProperties . getDos ( ) . getFilter ( ) , securityProperties . getClients ( ) ) ; filterRegBean . setUrlPatterns ( Arrays . asList ( "/system/*" ) ) ; filterRegBean . setOrder ( DOS_FILTER_ORDER ) ; filterRegBean . setName ( "dosSystemFilter" ) ; return filterRegBean ; }
Filter to protect the hawkBit server system management interface against to many requests .
29,179
public static void addNewMapping ( final Class < ? > type , final String property , final String mapping ) { allowedColmns . computeIfAbsent ( type , k -> new HashMap < > ( ) ) ; allowedColmns . get ( type ) . put ( property , mapping ) ; }
Add new mapping - property name and alias .
29,180
public void clearUploadTempData ( ) { LOG . debug ( "Cleaning up temp data..." ) ; for ( final FileUploadProgress fileUploadProgress : getAllFileUploadProgressValuesFromOverallUploadProcessList ( ) ) { if ( ! StringUtils . isBlank ( fileUploadProgress . getFilePath ( ) ) ) { final boolean deleted = FileUtils . deleteQuietly ( new File ( fileUploadProgress . getFilePath ( ) ) ) ; if ( ! deleted ) { LOG . warn ( "TempFile was not deleted: {}" , fileUploadProgress . getFilePath ( ) ) ; } } } clearFileStates ( ) ; }
Clears all temp data collected while uploading files .
29,181
public boolean isUploadInProgressForSelectedSoftwareModule ( final Long softwareModuleId ) { for ( final FileUploadId fileUploadId : getAllFileUploadIdsFromOverallUploadProcessList ( ) ) { if ( fileUploadId . getSoftwareModuleId ( ) . equals ( softwareModuleId ) ) { return true ; } } return false ; }
Checks if an upload is in progress for the given Software Module
29,182
private static < T extends Enum < T > & FieldNameProvider > T getAttributeIdentifierByName ( final Class < T > enumType , final String name ) { try { return Enum . valueOf ( enumType , name . toUpperCase ( ) ) ; } catch ( final IllegalArgumentException e ) { throw new SortParameterUnsupportedFieldException ( e ) ; } }
Returns the attribute identifier for the given name .
29,183
@ EventListener ( classes = CancelTargetAssignmentEvent . class ) protected void targetCancelAssignmentToDistributionSet ( final CancelTargetAssignmentEvent cancelEvent ) { if ( isNotFromSelf ( cancelEvent ) ) { return ; } sendCancelMessageToTarget ( cancelEvent . getTenant ( ) , cancelEvent . getEntity ( ) . getControllerId ( ) , cancelEvent . getActionId ( ) , cancelEvent . getEntity ( ) . getAddress ( ) ) ; }
Method to send a message to a RabbitMQ Exchange after the assignment of the Distribution set to a Target has been canceled .
29,184
@ EventListener ( classes = TargetDeletedEvent . class ) protected void targetDelete ( final TargetDeletedEvent deleteEvent ) { if ( isNotFromSelf ( deleteEvent ) ) { return ; } sendDeleteMessage ( deleteEvent . getTenant ( ) , deleteEvent . getControllerId ( ) , deleteEvent . getTargetAddress ( ) ) ; }
Method to send a message to a RabbitMQ Exchange after a Target was deleted .
29,185
public void setValue ( final Object value ) { if ( ! ( value instanceof Serializable ) ) { throw new IllegalArgumentException ( "The value muste be a instance of " + Serializable . class . getName ( ) ) ; } this . value = ( Serializable ) value ; }
Sets the MgmtSystemTenantConfigurationValueRequest
29,186
public void populateSMMetadata ( final SoftwareModule swModule ) { removeAllItems ( ) ; if ( null == swModule ) { return ; } selectedSWModuleId = swModule . getId ( ) ; final List < SoftwareModuleMetadata > swMetadataList = softwareModuleManagement . findMetaDataBySoftwareModuleId ( PageRequest . of ( 0 , MAX_METADATA_QUERY ) , selectedSWModuleId ) . getContent ( ) ; if ( ! CollectionUtils . isEmpty ( swMetadataList ) ) { swMetadataList . forEach ( this :: setMetadataProperties ) ; } }
Populate software module metadata table .
29,187
public void update ( final List < Long > groupTargetCounts , final Long totalTargetCount ) { this . groupTargetCounts = groupTargetCounts ; this . totalTargetCount = totalTargetCount ; if ( groupTargetCounts != null ) { long sum = 0 ; for ( Long targetCount : groupTargetCounts ) { sum += targetCount ; } unassignedTargets = totalTargetCount - sum ; } draw ( ) ; }
Updates the pie chart with new data
29,188
private Boolean doValidations ( final DragAndDropEvent dragEvent ) { final Component compsource = dragEvent . getTransferable ( ) . getSourceComponent ( ) ; Boolean isValid = Boolean . TRUE ; if ( compsource instanceof Table && ! isComplexFilterViewDisplayed ) { final TableTransferable transferable = ( TableTransferable ) dragEvent . getTransferable ( ) ; final Table source = transferable . getSourceComponent ( ) ; if ( ! source . getId ( ) . equals ( UIComponentIdProvider . DIST_TABLE_ID ) ) { notification . displayValidationError ( i18n . getMessage ( UIMessageIdProvider . MESSAGE_ACTION_NOT_ALLOWED ) ) ; isValid = Boolean . FALSE ; } else { if ( getDropppedDistributionDetails ( transferable ) . size ( ) > 1 ) { notification . displayValidationError ( i18n . getMessage ( "message.onlyone.distribution.dropallowed" ) ) ; isValid = Boolean . FALSE ; } } } else { notification . displayValidationError ( i18n . getMessage ( UIMessageIdProvider . MESSAGE_ACTION_NOT_ALLOWED ) ) ; isValid = Boolean . FALSE ; } return isValid ; }
Validation for drag event .
29,189
public ResponseEntity < Void > deleteTenant ( @ PathVariable ( "tenant" ) final String tenant ) { systemManagement . deleteTenant ( tenant ) ; return ResponseEntity . ok ( ) . build ( ) ; }
Deletes the tenant data of a given tenant . USE WITH CARE!
29,190
public ResponseEntity < MgmtSystemStatisticsRest > getSystemUsageStats ( ) { final SystemUsageReportWithTenants report = systemManagement . getSystemUsageStatisticsWithTenants ( ) ; final MgmtSystemStatisticsRest result = new MgmtSystemStatisticsRest ( ) . setOverallActions ( report . getOverallActions ( ) ) . setOverallArtifacts ( report . getOverallArtifacts ( ) ) . setOverallArtifactVolumeInBytes ( report . getOverallArtifactVolumeInBytes ( ) ) . setOverallTargets ( report . getOverallTargets ( ) ) . setOverallTenants ( report . getTenants ( ) . size ( ) ) ; result . setTenantStats ( report . getTenants ( ) . stream ( ) . map ( MgmtSystemManagementResource :: convertTenant ) . collect ( Collectors . toList ( ) ) ) ; return ResponseEntity . ok ( result ) ; }
Collects and returns system usage statistics . It provides a system wide overview and tenant based stats .
29,191
@ PreAuthorize ( SpringEvalExpressions . HAS_AUTH_SYSTEM_ADMIN ) public ResponseEntity < Collection < MgmtSystemCache > > getCaches ( ) { final Collection < String > cacheNames = cacheManager . getCacheNames ( ) ; return ResponseEntity . ok ( cacheNames . stream ( ) . map ( cacheManager :: getCache ) . map ( this :: cacheRest ) . collect ( Collectors . toList ( ) ) ) ; }
Returns a list of all caches .
29,192
@ PreAuthorize ( SpringEvalExpressions . HAS_AUTH_SYSTEM_ADMIN ) public ResponseEntity < Collection < String > > invalidateCaches ( ) { final Collection < String > cacheNames = cacheManager . getCacheNames ( ) ; LOGGER . info ( "Invalidating caches {}" , cacheNames ) ; cacheNames . forEach ( cacheName -> cacheManager . getCache ( cacheName ) . clear ( ) ) ; return ResponseEntity . ok ( cacheNames ) ; }
Invalidates all caches for all tenants .
29,193
protected void init ( final String labelText ) { setImmediate ( true ) ; addComponent ( new LabelBuilder ( ) . name ( i18n . getMessage ( labelText ) ) . buildLabel ( ) ) ; }
initialize the abstract component .
29,194
public Map < String , Object > getDeadLetterExchangeArgs ( final String exchange ) { final Map < String , Object > args = Maps . newHashMapWithExpectedSize ( 1 ) ; args . put ( "x-dead-letter-exchange" , exchange ) ; return args ; }
Return the deadletter arguments .
29,195
public Queue createDeadletterQueue ( final String queueName ) { return new Queue ( queueName , true , false , false , getTTLArgs ( ) ) ; }
Create a deadletter queue with ttl for messages
29,196
public void updateTarget ( ) { final Target target = targetManagement . update ( entityFactory . target ( ) . update ( controllerId ) . name ( nameTextField . getValue ( ) ) . description ( descTextArea . getValue ( ) ) ) ; uINotification . displaySuccess ( i18n . getMessage ( "message.update.success" , target . getName ( ) ) ) ; eventBus . publish ( this , new TargetTableEvent ( BaseEntityEventType . UPDATED_ENTITY , target ) ) ; }
Update the Target if modified .
29,197
public Window getWindow ( final String controllerId ) { final Optional < Target > target = targetManagement . getByControllerID ( controllerId ) ; if ( ! target . isPresent ( ) ) { uINotification . displayWarning ( i18n . getMessage ( "target.not.exists" , controllerId ) ) ; return null ; } populateValuesOfTarget ( target . get ( ) ) ; createNewWindow ( ) ; window . setCaption ( i18n . getMessage ( "caption.update" , i18n . getMessage ( "caption.target" ) ) ) ; window . addStyleName ( "target-update-window" ) ; return window ; }
Returns Target Update window based on the selected Entity Id in the target table .
29,198
public void resetComponents ( ) { nameTextField . clear ( ) ; nameTextField . removeStyleName ( SPUIStyleDefinitions . SP_TEXTFIELD_ERROR ) ; controllerIDTextField . setEnabled ( Boolean . TRUE ) ; controllerIDTextField . removeStyleName ( SPUIStyleDefinitions . SP_TEXTFIELD_ERROR ) ; controllerIDTextField . clear ( ) ; descTextArea . clear ( ) ; editTarget = Boolean . FALSE ; }
clear all fields of Target Edit Window .
29,199
public static String getColorPickedString ( final SpColorPickerPreview preview ) { final Color color = preview . getColor ( ) ; return "rgb(" + color . getRed ( ) + "," + color . getGreen ( ) + "," + color . getBlue ( ) + ")" ; }
Get color picked value as string .