idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
42,900 | public Throwable getThrowable ( Object [ ] args ) { Throwable rv = null ; if ( args . length > 0 ) { if ( args [ args . length - 1 ] instanceof Throwable ) { rv = ( Throwable ) args [ args . length - 1 ] ; } } return rv ; } | Get the throwable from the last element of this array if it is Throwable else null . | 68 | 19 |
42,901 | public void trace ( Object message , Throwable exception ) { log ( Level . TRACE , message , exception ) ; } | Log a message at trace level . | 25 | 7 |
42,902 | public void trace ( String message , Object ... args ) { if ( isDebugEnabled ( ) ) { trace ( String . format ( message , args ) , getThrowable ( args ) ) ; } } | Log a formatted message at trace level . | 42 | 8 |
42,903 | public void debug ( Object message , Throwable exception ) { log ( Level . DEBUG , message , exception ) ; } | Log a message at debug level . | 24 | 7 |
42,904 | public void info ( String message , Object ... args ) { if ( isInfoEnabled ( ) ) { info ( String . format ( message , args ) , getThrowable ( args ) ) ; } } | Log a formatted message at info level . | 42 | 8 |
42,905 | public void warn ( Object message , Throwable exception ) { log ( Level . WARN , message , exception ) ; } | Log a message at warning level . | 24 | 7 |
42,906 | public void error ( Object message , Throwable exception ) { log ( Level . ERROR , message , exception ) ; } | Log a message at error level . | 24 | 7 |
42,907 | public void fatal ( Object message , Throwable exception ) { log ( Level . FATAL , message , exception ) ; } | Log a message at fatal level . | 25 | 7 |
42,908 | @ Override public void log ( Level level , Object message , Throwable e ) { if ( level == null ) { level = Level . FATAL ; } switch ( level ) { case TRACE : logger . trace ( message . toString ( ) , e ) ; break ; case DEBUG : logger . debug ( message . toString ( ) , e ) ; break ; case INFO : logger . info ( message . ... | Wrapper around SLF4J logger facade . | 190 | 10 |
42,909 | public synchronized void authConnection ( MemcachedConnection conn , OperationFactory opFact , AuthDescriptor authDescriptor , MemcachedNode node ) { interruptOldAuth ( node ) ; AuthThread newSASLAuthenticator = new AuthThread ( conn , opFact , authDescriptor , node ) ; nodeMap . put ( node , newSASLAuthenticator ) ; } | Authenticate a new connection . This is typically used by a MemcachedNode in order to authenticate a connection right after it has been established . | 84 | 30 |
42,910 | private void parseHeaderFromBuffer ( ) { int magic = header [ 0 ] ; assert magic == RES_MAGIC : "Invalid magic: " + magic ; responseCmd = header [ 1 ] ; assert cmd == DUMMY_OPCODE || responseCmd == cmd : "Unexpected response command value" ; keyLen = decodeShort ( header , 2 ) ; errorCode = decodeShort ( header , 6 ) ;... | Parse the header info out of the buffer . | 151 | 10 |
42,911 | private void readPayloadFromBuffer ( final ByteBuffer buffer ) throws IOException { int toRead = payload . length - payloadOffset ; int available = buffer . remaining ( ) ; toRead = Math . min ( toRead , available ) ; getLogger ( ) . debug ( "Reading %d payload bytes" , toRead ) ; buffer . get ( payload , payloadOffset... | Read the payload from the buffer . | 108 | 7 |
42,912 | protected OperationStatus getStatusForErrorCode ( int errCode , byte [ ] errPl ) throws IOException { if ( errCode == SUCCESS ) { return STATUS_OK ; } else { StatusCode statusCode = StatusCode . fromBinaryCode ( errCode ) ; errorMsg = errPl . clone ( ) ; switch ( errCode ) { case ERR_NOT_FOUND : return new CASOperation... | Get the OperationStatus object for the given error code . | 319 | 11 |
42,913 | protected void prepareBuffer ( final String key , final long cas , final byte [ ] val , final Object ... extraHeaders ) { int extraLen = 0 ; int extraHeadersLength = extraHeaders . length ; if ( extraHeadersLength > 0 ) { extraLen = calculateExtraLength ( extraHeaders ) ; } final byte [ ] keyBytes = KeyUtil . getKeyByt... | Prepare the buffer for sending . | 303 | 7 |
42,914 | private void initReporter ( ) { String reporterType = System . getProperty ( "net.spy.metrics.reporter.type" , DEFAULT_REPORTER_TYPE ) ; String reporterInterval = System . getProperty ( "net.spy.metrics.reporter.interval" , DEFAULT_REPORTER_INTERVAL ) ; String reporterDir = System . getProperty ( "net.spy.metrics.repor... | Initialize the proper metrics Reporter . | 497 | 7 |
42,915 | public ResponseMessage getNextMessage ( long time , TimeUnit timeunit ) { try { Object m = rqueue . poll ( time , timeunit ) ; if ( m == null ) { return null ; } else if ( m instanceof ResponseMessage ) { return ( ResponseMessage ) m ; } else if ( m instanceof TapAck ) { TapAck ack = ( TapAck ) m ; tapAck ( ack . getCo... | Gets the next tap message from the queue of received tap messages . | 172 | 14 |
42,916 | public boolean hasMoreMessages ( ) { if ( ! rqueue . isEmpty ( ) ) { return true ; } else { synchronized ( omap ) { Iterator < TapStream > itr = omap . keySet ( ) . iterator ( ) ; while ( itr . hasNext ( ) ) { TapStream ts = itr . next ( ) ; if ( ts . isCompleted ( ) || ts . isCancelled ( ) || ts . hasErrored ( ) ) { o... | Decides whether the client has received tap messages or will receive more messages in the future . | 147 | 18 |
42,917 | public TapStream tapCustom ( final String id , final RequestMessage message ) throws ConfigurationException , IOException { final TapConnectionProvider conn = new TapConnectionProvider ( addrs ) ; final TapStream ts = new TapStream ( ) ; conn . broadcastOp ( new BroadcastOpFactory ( ) { public Operation newOp ( final M... | Allows the user to specify a custom tap message . | 246 | 10 |
42,918 | public void shutdown ( ) { synchronized ( omap ) { for ( Map . Entry < TapStream , TapConnectionProvider > me : omap . entrySet ( ) ) { me . getValue ( ) . shutdown ( ) ; } } } | Shuts down all tap streams that are currently running . | 50 | 11 |
42,919 | public static long fieldToValue ( byte [ ] buffer , int offset , int length ) { long total = 0 ; long val = 0 ; for ( int i = 0 ; i < length ; i ++ ) { val = buffer [ offset + i ] ; if ( val < 0 ) { val = val + 256 ; } total += ( long ) Math . pow ( 256.0 , ( double ) ( length - 1 - i ) ) * val ; } return total ; } | Converts a field in a byte array into a value . | 99 | 12 |
42,920 | public static void valueToFieldOffest ( byte [ ] buffer , int offset , int length , long l ) { long divisor ; for ( int i = 0 ; i < length ; i ++ ) { divisor = ( long ) Math . pow ( 256.0 , ( double ) ( length - 1 - i ) ) ; buffer [ offset + i ] = ( byte ) ( l / divisor ) ; l = l % divisor ; } } | Puts a value into a specific location in a byte buffer . | 99 | 13 |
42,921 | protected final synchronized void transitionState ( OperationState newState ) { getLogger ( ) . debug ( "Transitioned state from %s to %s" , state , newState ) ; state = newState ; // Discard our buffer when we no longer need it. if ( state != OperationState . WRITE_QUEUED && state != OperationState . WRITING ) { cmd =... | Transition the state of this operation to the given state . | 105 | 12 |
42,922 | public boolean isCompleted ( ) { for ( TapOperation op : ops ) { if ( ! op . getState ( ) . equals ( OperationState . COMPLETE ) ) { return false ; } } return true ; } | Check if all operations in the TapStream are completed . | 45 | 11 |
42,923 | public void setFlags ( TapRequestFlag f ) { if ( ! flagList . contains ( f ) ) { if ( ! hasFlags ) { hasFlags = true ; extralength += 4 ; totalbody += 4 ; } if ( f . equals ( TapRequestFlag . BACKFILL ) ) { hasBackfill = true ; totalbody += 8 ; } if ( f . equals ( TapRequestFlag . LIST_VBUCKETS ) || f . equals ( TapReq... | Sets the flags for the tap stream . These flags decide what kind of tap stream will be received . | 165 | 21 |
42,924 | public void setVbucketlist ( short [ ] vbs ) { int oldSize = ( vblist . length + 1 ) * 2 ; int newSize = ( vbs . length + 1 ) * 2 ; totalbody += newSize - oldSize ; vblist = vbs ; } | Sets a list of vbuckets to stream keys from . | 63 | 13 |
42,925 | public void setvBucketCheckpoints ( Map < Short , Long > vbchkpnts ) { int oldSize = ( vBucketCheckpoints . size ( ) ) * 10 ; int newSize = ( vbchkpnts . size ( ) ) * 10 ; totalbody += newSize - oldSize ; vBucketCheckpoints = vbchkpnts ; } | Sets a map of vbucket checkpoints . | 86 | 10 |
42,926 | public void setName ( String n ) { if ( n . length ( ) > 65535 ) { throw new IllegalArgumentException ( "Tap name too long" ) ; } totalbody += n . length ( ) - name . length ( ) ; keylength = ( short ) n . length ( ) ; name = n ; } | Sets a name for this tap stream . If the tap stream fails this name can be used to try to restart the tap stream from where it last left off . | 69 | 33 |
42,927 | @ Override public ByteBuffer getBytes ( ) { ByteBuffer bb = ByteBuffer . allocate ( HEADER_LENGTH + getTotalbody ( ) ) ; bb . put ( magic . getMagic ( ) ) ; bb . put ( opcode . getOpcode ( ) ) ; bb . putShort ( keylength ) ; bb . put ( extralength ) ; bb . put ( datatype ) ; bb . putShort ( vbucket ) ; bb . putInt ( to... | Encodes the message into binary . | 374 | 7 |
42,928 | protected Future < T > addToListeners ( final GenericCompletionListener < ? extends Future < T > > listener ) { if ( listener == null ) { throw new IllegalArgumentException ( "The listener can't be null." ) ; } synchronized ( this ) { listeners . add ( listener ) ; } if ( isDone ( ) ) { notifyListeners ( ) ; } return t... | Add the given listener to the total list of listeners to be notified . | 83 | 14 |
42,929 | protected void notifyListener ( final ExecutorService executor , final Future < ? > future , final GenericCompletionListener listener ) { executor . submit ( new Runnable ( ) { @ Override public void run ( ) { try { listener . onComplete ( future ) ; } catch ( Throwable t ) { getLogger ( ) . warn ( "Exception thrown wi... | Notify a specific listener of completion . | 109 | 8 |
42,930 | protected void notifyListeners ( final Future < ? > future ) { final List < GenericCompletionListener < ? extends Future < T > > > copy = new ArrayList < GenericCompletionListener < ? extends Future < T > > > ( ) ; synchronized ( this ) { copy . addAll ( listeners ) ; listeners = new ArrayList < GenericCompletionListen... | Notify all registered listeners with a special future on completion . | 124 | 12 |
42,931 | protected Future < T > removeFromListeners ( GenericCompletionListener < ? extends Future < T > > listener ) { if ( listener == null ) { throw new IllegalArgumentException ( "The listener can't be null." ) ; } if ( ! isDone ( ) ) { synchronized ( this ) { listeners . remove ( listener ) ; } } return this ; } | Remove a listener from the list of registered listeners . | 77 | 10 |
42,932 | protected void registerMetrics ( ) { if ( metricType . equals ( MetricType . DEBUG ) || metricType . equals ( MetricType . PERFORMANCE ) ) { metrics . addHistogram ( OVERALL_AVG_BYTES_READ_METRIC ) ; metrics . addHistogram ( OVERALL_AVG_BYTES_WRITE_METRIC ) ; metrics . addHistogram ( OVERALL_AVG_TIME_ON_WIRE_METRIC ) ;... | Register Metrics for collection . | 254 | 6 |
42,933 | protected List < MemcachedNode > createConnections ( final Collection < InetSocketAddress > addrs ) throws IOException { List < MemcachedNode > connections = new ArrayList < MemcachedNode > ( addrs . size ( ) ) ; for ( SocketAddress sa : addrs ) { SocketChannel ch = SocketChannel . open ( ) ; ch . configureBlocking ( f... | Create connections for the given list of addresses . | 362 | 9 |
42,934 | private boolean selectorsMakeSense ( ) { for ( MemcachedNode qa : locator . getAll ( ) ) { if ( qa . getSk ( ) != null && qa . getSk ( ) . isValid ( ) ) { if ( qa . getChannel ( ) . isConnected ( ) ) { int sops = qa . getSk ( ) . interestOps ( ) ; int expected = 0 ; if ( qa . hasReadOp ( ) ) { expected |= SelectionKey ... | Make sure that the current selectors make sense . | 267 | 10 |
42,935 | public void handleIO ( ) throws IOException { if ( shutDown ) { getLogger ( ) . debug ( "No IO while shut down." ) ; return ; } handleInputQueue ( ) ; getLogger ( ) . debug ( "Done dealing with queue." ) ; long delay = wakeupDelay ; if ( ! reconnectQueue . isEmpty ( ) ) { long now = System . currentTimeMillis ( ) ; lon... | Handle all IO that flows through the connection . | 327 | 9 |
42,936 | private void handleShutdownQueue ( ) throws IOException { for ( MemcachedNode qa : nodesToShutdown ) { if ( ! addedQueue . contains ( qa ) ) { nodesToShutdown . remove ( qa ) ; metrics . decrementCounter ( SHUTD_QUEUE_METRIC ) ; Collection < Operation > notCompletedOperations = qa . destroyInputQueue ( ) ; if ( qa . ge... | Check if nodes need to be shut down and do so if needed . | 212 | 14 |
42,937 | private void checkPotentiallyTimedOutConnection ( ) { boolean stillCheckingTimeouts = true ; while ( stillCheckingTimeouts ) { try { for ( SelectionKey sk : selector . keys ( ) ) { MemcachedNode mn = ( MemcachedNode ) sk . attachment ( ) ; if ( mn . getContinuousTimeout ( ) > timeoutExceptionThreshold ) { getLogger ( )... | Check if one or more nodes exceeded the timeout Threshold . | 162 | 12 |
42,938 | private void handleInputQueue ( ) { if ( ! addedQueue . isEmpty ( ) ) { getLogger ( ) . debug ( "Handling queue" ) ; Collection < MemcachedNode > toAdd = new HashSet < MemcachedNode > ( ) ; Collection < MemcachedNode > todo = new HashSet < MemcachedNode > ( ) ; MemcachedNode qaNode ; while ( ( qaNode = addedQueue . pol... | Handle any requests that have been made against the client . | 295 | 11 |
42,939 | private void connected ( final MemcachedNode node ) { assert node . getChannel ( ) . isConnected ( ) : "Not connected." ; int rt = node . getReconnectCount ( ) ; node . connected ( ) ; for ( ConnectionObserver observer : connObservers ) { observer . connectionEstablished ( node . getSocketAddress ( ) , rt ) ; } } | Indicate a successful connect to the given node . | 84 | 10 |
42,940 | private void lostConnection ( final MemcachedNode node ) { queueReconnect ( node ) ; for ( ConnectionObserver observer : connObservers ) { observer . connectionLost ( node . getSocketAddress ( ) ) ; } } | Indicate a lost connection to the given node . | 50 | 10 |
42,941 | boolean belongsToCluster ( final MemcachedNode node ) { for ( MemcachedNode n : locator . getAll ( ) ) { if ( n . getSocketAddress ( ) . equals ( node . getSocketAddress ( ) ) ) { return true ; } } return false ; } | Makes sure that the given node belongs to the current cluster . | 63 | 13 |
42,942 | private void handleIO ( final SelectionKey sk ) { MemcachedNode node = ( MemcachedNode ) sk . attachment ( ) ; try { getLogger ( ) . debug ( "Handling IO for: %s (r=%s, w=%s, c=%s, op=%s)" , sk , sk . isReadable ( ) , sk . isWritable ( ) , sk . isConnectable ( ) , sk . attachment ( ) ) ; if ( sk . isConnectable ( ) && ... | Handle IO for a specific selector . | 429 | 7 |
42,943 | private void finishConnect ( final SelectionKey sk , final MemcachedNode node ) throws IOException { if ( verifyAliveOnConnect ) { final CountDownLatch latch = new CountDownLatch ( 1 ) ; final OperationFuture < Boolean > rv = new OperationFuture < Boolean > ( "noop" , latch , 2500 , listenerExecutorService ) ; NoopOper... | Finish the connect phase and potentially verify its liveness . | 393 | 11 |
42,944 | private void handleWrites ( final MemcachedNode node ) throws IOException { node . fillWriteBuffer ( shouldOptimize ) ; boolean canWriteMore = node . getBytesRemainingToWrite ( ) > 0 ; while ( canWriteMore ) { int wrote = node . writeSome ( ) ; metrics . updateHistogram ( OVERALL_AVG_BYTES_WRITE_METRIC , wrote ) ; node... | Handle pending writes for the given node . | 122 | 8 |
42,945 | private void handleReads ( final MemcachedNode node ) throws IOException { Operation currentOp = node . getCurrentReadOp ( ) ; if ( currentOp instanceof TapAckOperationImpl ) { node . removeCurrentReadOp ( ) ; return ; } ByteBuffer rbuf = node . getRbuf ( ) ; final SocketChannel channel = node . getChannel ( ) ; int re... | Handle pending reads for the given node . | 347 | 8 |
42,946 | private void readBufferAndLogMetrics ( final Operation currentOp , final ByteBuffer rbuf , final MemcachedNode node ) throws IOException { currentOp . readFromBuffer ( rbuf ) ; if ( currentOp . getState ( ) == OperationState . COMPLETE ) { getLogger ( ) . debug ( "Completed read op: %s and giving the next %d " + "bytes... | Read from the buffer and add metrics information . | 353 | 9 |
42,947 | private Operation handleReadsWhenChannelEndOfStream ( final Operation currentOp , final MemcachedNode node , final ByteBuffer rbuf ) throws IOException { if ( currentOp instanceof TapOperation ) { currentOp . getCallback ( ) . complete ( ) ; ( ( TapOperation ) currentOp ) . streamClosed ( OperationState . COMPLETE ) ; ... | Deal with an operation where the channel reached the end of a stream . | 174 | 14 |
42,948 | private void potentiallyCloseLeakingChannel ( final SocketChannel ch , final MemcachedNode node ) { if ( ch != null && ! ch . isConnected ( ) && ! ch . isConnectionPending ( ) ) { try { ch . close ( ) ; } catch ( IOException e ) { getLogger ( ) . error ( "Exception closing channel: %s" , node , e ) ; } } } | Make sure channel connections are not leaked and properly close under faulty reconnect cirumstances . | 88 | 18 |
42,949 | protected void addOperation ( final String key , final Operation o ) { MemcachedNode placeIn = null ; MemcachedNode primary = locator . getPrimary ( key ) ; if ( primary . isActive ( ) || failureMode == FailureMode . Retry ) { placeIn = primary ; } else if ( failureMode == FailureMode . Cancel ) { o . cancel ( ) ; } el... | Add an operation to a connection identified by the given key . | 275 | 12 |
42,950 | public void insertOperation ( final MemcachedNode node , final Operation o ) { o . setHandlingNode ( node ) ; o . initialize ( ) ; node . insertOp ( o ) ; addedQueue . offer ( node ) ; metrics . markMeter ( OVERALL_REQUEST_METRIC ) ; Selector s = selector . wakeup ( ) ; assert s == selector : "Wakeup returned the wrong... | Insert an operation on the given node to the beginning of the queue . | 114 | 14 |
42,951 | protected void addOperation ( final MemcachedNode node , final Operation o ) { if ( ! node . isAuthenticated ( ) ) { retryOperation ( o ) ; return ; } o . setHandlingNode ( node ) ; o . initialize ( ) ; node . addOp ( o ) ; addedQueue . offer ( node ) ; metrics . markMeter ( OVERALL_REQUEST_METRIC ) ; Selector s = sele... | Enqueue an operation on the given node . | 136 | 9 |
42,952 | public void addOperations ( final Map < MemcachedNode , Operation > ops ) { for ( Map . Entry < MemcachedNode , Operation > me : ops . entrySet ( ) ) { addOperation ( me . getKey ( ) , me . getValue ( ) ) ; } } | Enqueue the given list of operations on each handling node . | 62 | 12 |
42,953 | public CountDownLatch broadcastOperation ( final BroadcastOpFactory of , final Collection < MemcachedNode > nodes ) { final CountDownLatch latch = new CountDownLatch ( nodes . size ( ) ) ; for ( MemcachedNode node : nodes ) { getLogger ( ) . debug ( "broadcast Operation: node = " + node ) ; Operation op = of . newOp ( ... | Broadcast an operation to a collection of nodes . | 168 | 10 |
42,954 | public void shutdown ( ) throws IOException { shutDown = true ; try { Selector s = selector . wakeup ( ) ; assert s == selector : "Wakeup returned the wrong selector." ; for ( MemcachedNode node : locator . getAll ( ) ) { if ( node . getChannel ( ) != null ) { node . getChannel ( ) . close ( ) ; node . setSk ( null ) ;... | Shut down all connections and do not accept further incoming ops . | 199 | 12 |
42,955 | public String connectionsStatus ( ) { StringBuilder connStatus = new StringBuilder ( ) ; connStatus . append ( "Connection Status {" ) ; for ( MemcachedNode node : locator . getAll ( ) ) { connStatus . append ( " " ) . append ( node . getSocketAddress ( ) ) . append ( " active: " ) . append ( node . isActive ( ) ) . ap... | Construct a String containing information about all nodes and their state . | 153 | 12 |
42,956 | private static void setTimeout ( final Operation op , final boolean isTimeout ) { Logger logger = LoggerFactory . getLogger ( MemcachedConnection . class ) ; try { if ( op == null || op . isTimedOutUnsent ( ) ) { return ; } MemcachedNode node = op . getHandlingNode ( ) ; if ( node != null ) { node . setContinuousTimeou... | Set the continuous timeout on an operation . | 114 | 8 |
42,957 | @ Override public void run ( ) { while ( running ) { try { handleIO ( ) ; } catch ( IOException e ) { logRunException ( e ) ; } catch ( CancelledKeyException e ) { logRunException ( e ) ; } catch ( ClosedSelectorException e ) { logRunException ( e ) ; } catch ( IllegalStateException e ) { logRunException ( e ) ; } catc... | Handle IO as long as the application is running . | 125 | 10 |
42,958 | private void logRunException ( final Exception e ) { if ( shutDown ) { getLogger ( ) . debug ( "Exception occurred during shutdown" , e ) ; } else { getLogger ( ) . warn ( "Problem handling memcached IO" , e ) ; } } | Log a exception to different levels depending on the state . | 60 | 11 |
42,959 | public void retryOperation ( Operation op ) { if ( retryQueueSize >= 0 && retryOps . size ( ) >= retryQueueSize ) { if ( ! op . isCancelled ( ) ) { op . cancel ( ) ; } } retryOps . add ( op ) ; } | Add a operation to the retry queue . | 64 | 9 |
42,960 | public < T > Future < T > decode ( final Transcoder < T > tc , final CachedData cachedData ) { assert ! pool . isShutdown ( ) : "Pool has already shut down." ; TranscodeService . Task < T > task = new TranscodeService . Task < T > ( new Callable < T > ( ) { public T call ( ) { return tc . decode ( cachedData ) ; } } ) ... | Perform a decode . | 120 | 5 |
42,961 | private Object deserialize ( ) { SerializingTranscoder tc = new SerializingTranscoder ( ) ; CachedData d = new CachedData ( this . getItemFlags ( ) , this . getValue ( ) , CachedData . MAX_SIZE ) ; Object rv = null ; rv = tc . decode ( d ) ; return rv ; } | Attempt to get the object represented by the given serialized bytes . | 79 | 13 |
42,962 | public static void close ( Closeable closeable ) { if ( closeable != null ) { try { closeable . close ( ) ; } catch ( Exception e ) { logger . info ( "Unable to close %s" , closeable , e ) ; } } } | Close a closeable . | 57 | 5 |
42,963 | public static synchronized HashAlgorithm lookupHashAlgorithm ( String name ) { validateName ( name ) ; return REGISTRY . get ( name . toLowerCase ( ) ) ; } | Tries to find selected hash algorithm using name provided . | 38 | 11 |
42,964 | @ Override public Collection < SocketAddress > getUnavailableServers ( ) { ArrayList < SocketAddress > rv = new ArrayList < SocketAddress > ( ) ; for ( MemcachedNode node : mconn . getLocator ( ) . getAll ( ) ) { if ( ! node . isActive ( ) ) { rv . add ( node . getSocketAddress ( ) ) ; } } return rv ; } | Get the addresses of unavailable servers . | 91 | 7 |
42,965 | @ Override public < T > OperationFuture < Boolean > touch ( final String key , final int exp ) { return touch ( key , exp , transcoder ) ; } | Touch the given key to reset its expiration time with the default transcoder . | 35 | 15 |
42,966 | @ Override public < T > OperationFuture < Boolean > touch ( final String key , final int exp , final Transcoder < T > tc ) { final CountDownLatch latch = new CountDownLatch ( 1 ) ; final OperationFuture < Boolean > rv = new OperationFuture < Boolean > ( key , latch , operationTimeout , executorService ) ; Operation op ... | Touch the given key to reset its expiration time . | 177 | 10 |
42,967 | @ Override public OperationFuture < CASResponse > asyncCAS ( String key , long casId , Object value ) { return asyncCAS ( key , casId , value , transcoder ) ; } | Asynchronous CAS operation using the default transcoder . | 42 | 10 |
42,968 | @ Override public CASResponse cas ( String key , long casId , Object value ) { return cas ( key , casId , value , transcoder ) ; } | Perform a synchronous CAS operation with the default transcoder . | 34 | 13 |
42,969 | @ Override public < T > OperationFuture < Boolean > add ( String key , int exp , T o , Transcoder < T > tc ) { return asyncStore ( StoreType . add , key , exp , o , tc ) ; } | Add an object to the cache iff it does not exist already . | 51 | 14 |
42,970 | @ Override public < T > GetFuture < T > asyncGet ( final String key , final Transcoder < T > tc ) { final CountDownLatch latch = new CountDownLatch ( 1 ) ; final GetFuture < T > rv = new GetFuture < T > ( latch , operationTimeout , key , executorService ) ; Operation op = opFact . get ( key , new GetOperation . Callbac... | Get the given key asynchronously . | 241 | 8 |
42,971 | @ Override public < T > CASValue < T > getAndTouch ( String key , int exp , Transcoder < T > tc ) { try { return asyncGetAndTouch ( key , exp , tc ) . get ( operationTimeout , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( "Interrupted waiting for value" , e ) ; } catch ( ... | Get with a single key and reset its expiration . | 170 | 10 |
42,972 | @ Override public CASValue < Object > getAndTouch ( String key , int exp ) { return getAndTouch ( key , exp , transcoder ) ; } | Get a single key and reset its expiration using the default transcoder . | 34 | 14 |
42,973 | @ Override public < T > T get ( String key , Transcoder < T > tc ) { try { return asyncGet ( key , tc ) . get ( operationTimeout , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( "Interrupted waiting for value" , e ) ; } catch ( ExecutionException e ) { if ( e . getCause ( ... | Get with a single key . | 175 | 6 |
42,974 | @ Override public < T > BulkFuture < Map < String , T > > asyncGetBulk ( Transcoder < T > tc , String ... keys ) { return asyncGetBulk ( Arrays . asList ( keys ) , tc ) ; } | Varargs wrapper for asynchronous bulk gets . | 54 | 8 |
42,975 | @ Override public BulkFuture < Map < String , Object > > asyncGetBulk ( String ... keys ) { return asyncGetBulk ( Arrays . asList ( keys ) , transcoder ) ; } | Varargs wrapper for asynchronous bulk gets with the default transcoder . | 44 | 13 |
42,976 | @ Override public OperationFuture < CASValue < Object > > asyncGetAndTouch ( final String key , final int exp ) { return asyncGetAndTouch ( key , exp , transcoder ) ; } | Get the given key to reset its expiration time . | 42 | 10 |
42,977 | @ Override public Map < SocketAddress , String > getVersions ( ) { final Map < SocketAddress , String > rv = new ConcurrentHashMap < SocketAddress , String > ( ) ; CountDownLatch blatch = broadcastOp ( new BroadcastOpFactory ( ) { @ Override public Operation newOp ( final MemcachedNode n , final CountDownLatch latch ) ... | Get the versions of all of the connected memcacheds . | 210 | 13 |
42,978 | @ Override public Map < SocketAddress , Map < String , String > > getStats ( final String arg ) { final Map < SocketAddress , Map < String , String > > rv = new HashMap < SocketAddress , Map < String , String > > ( ) ; CountDownLatch blatch = broadcastOp ( new BroadcastOpFactory ( ) { @ Override public Operation newOp ... | Get a set of stats from all connections . | 314 | 9 |
42,979 | @ Override public long incr ( String key , int by ) { return mutate ( Mutator . incr , key , by , 0 , - 1 ) ; } | Increment the given key by the given amount . | 36 | 10 |
42,980 | @ Override public long decr ( String key , long by ) { return mutate ( Mutator . decr , key , by , 0 , - 1 ) ; } | Decrement the given key by the given value . | 36 | 10 |
42,981 | @ Override public OperationFuture < Long > asyncDecr ( String key , int by , long def , int exp ) { return asyncMutate ( Mutator . decr , key , by , def , exp ) ; } | Asynchronous decrement . | 47 | 5 |
42,982 | @ Override public OperationFuture < Long > asyncIncr ( String key , long by , long def ) { return asyncMutate ( Mutator . incr , key , by , def , 0 ) ; } | Asychronous increment . | 44 | 6 |
42,983 | @ Override public long incr ( String key , long by , long def ) { return mutateWithDefault ( Mutator . incr , key , by , def , 0 ) ; } | Increment the given counter returning the new value . | 40 | 10 |
42,984 | @ Override public OperationFuture < Boolean > delete ( String key , long cas ) { final CountDownLatch latch = new CountDownLatch ( 1 ) ; final OperationFuture < Boolean > rv = new OperationFuture < Boolean > ( key , latch , operationTimeout , executorService ) ; DeleteOperation . Callback callback = new DeleteOperation... | Delete the given key from the cache of the given CAS value applies . | 223 | 14 |
42,985 | @ Override public OperationFuture < Boolean > flush ( final int delay ) { final AtomicReference < Boolean > flushResult = new AtomicReference < Boolean > ( null ) ; final ConcurrentLinkedQueue < Operation > ops = new ConcurrentLinkedQueue < Operation > ( ) ; CountDownLatch blatch = broadcastOp ( new BroadcastOpFactory ... | Flush all caches from all servers with a delay of application . | 453 | 13 |
42,986 | @ Override public boolean waitForQueues ( long timeout , TimeUnit unit ) { CountDownLatch blatch = broadcastOp ( new BroadcastOpFactory ( ) { @ Override public Operation newOp ( final MemcachedNode n , final CountDownLatch latch ) { return opFact . noop ( new OperationCallback ( ) { @ Override public void complete ( ) ... | Wait for the queues to die down . | 197 | 8 |
42,987 | public ConnectionFactoryBuilder setProtocol ( Protocol prot ) { switch ( prot ) { case TEXT : opFact = new AsciiOperationFactory ( ) ; break ; case BINARY : opFact = new BinaryOperationFactory ( ) ; break ; default : assert false : "Unhandled protocol: " + prot ; } return this ; } | Convenience method to specify the protocol to use . | 70 | 11 |
42,988 | public T cas ( final String key , final T initial , int initialExp , final CASMutation < T > m ) throws Exception { T rv = initial ; boolean done = false ; for ( int i = 0 ; ! done && i < max ; i ++ ) { CASValue < T > casval = client . gets ( key , transcoder ) ; T current = null ; // If there were a CAS value, check t... | CAS a new value in for a key . | 421 | 10 |
42,989 | @ Override public void run ( ) { try { barrier . await ( ) ; rv = callable . call ( ) ; } catch ( Throwable t ) { throwable = t ; } latch . countDown ( ) ; } | Wait for the barrier invoke the callable and capture the result or an exception . | 49 | 16 |
42,990 | public static < T > Collection < SyncThread < T > > getCompletedThreads ( int num , Callable < T > callable ) throws InterruptedException { Collection < SyncThread < T >> rv = new ArrayList < SyncThread < T > > ( num ) ; CyclicBarrier barrier = new CyclicBarrier ( num ) ; for ( int i = 0 ; i < num ; i ++ ) { rv . add (... | Get a collection of SyncThreads that all began as close to the same time as possible and have all completed . | 133 | 23 |
42,991 | public static < T > int getDistinctResultCount ( int num , Callable < T > callable ) throws Throwable { IdentityHashMap < T , Object > found = new IdentityHashMap < T , Object > ( ) ; Collection < SyncThread < T > > threads = getCompletedThreads ( num , callable ) ; for ( SyncThread < T > s : threads ) { found . put ( ... | Get the distinct result count for the given callable at the given concurrency . | 108 | 16 |
42,992 | @ Override public void log ( Level level , Object message , Throwable e ) { org . apache . log4j . Level pLevel = org . apache . log4j . Level . DEBUG ; switch ( level == null ? Level . FATAL : level ) { case TRACE : pLevel = org . apache . log4j . Level . TRACE ; break ; case DEBUG : pLevel = org . apache . log4j . Le... | Wrapper around log4j . | 304 | 7 |
42,993 | protected String decodeString ( byte [ ] data ) { String rv = null ; try { if ( data != null ) { rv = new String ( data , charset ) ; } } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } return rv ; } | Decode the string with the current character set . | 64 | 10 |
42,994 | public < T > Future < ? > loadData ( Iterator < Map . Entry < String , T > > i ) { Future < Boolean > mostRecent = null ; while ( i . hasNext ( ) ) { Map . Entry < String , T > e = i . next ( ) ; mostRecent = push ( e . getKey ( ) , e . getValue ( ) ) ; watch ( e . getKey ( ) , mostRecent ) ; } return mostRecent == nul... | Load data from the given iterator . | 113 | 7 |
42,995 | public < T > Future < ? > loadData ( Map < String , T > map ) { return loadData ( map . entrySet ( ) . iterator ( ) ) ; } | Load data from the given map . | 37 | 7 |
42,996 | public < T > Future < Boolean > push ( String k , T value ) { Future < Boolean > rv = null ; while ( rv == null ) { try { rv = client . set ( k , expiration , value ) ; } catch ( IllegalStateException ex ) { // Need to slow down a bit when we start getting rejections. try { if ( rv != null ) { rv . get ( 250 , TimeUnit... | Push a value into the cache . | 162 | 7 |
42,997 | @ Override public void log ( Level level , Object message , Throwable e ) { java . util . logging . Level sLevel = java . util . logging . Level . SEVERE ; switch ( level == null ? Level . FATAL : level ) { case TRACE : sLevel = java . util . logging . Level . FINEST ; break ; case DEBUG : sLevel = java . util . loggin... | Wrapper around sun logger . | 587 | 6 |
42,998 | public static String join ( final Collection < String > chunks , final String delimiter ) { StringBuilder sb = new StringBuilder ( ) ; if ( ! chunks . isEmpty ( ) ) { Iterator < String > itr = chunks . iterator ( ) ; sb . append ( itr . next ( ) ) ; while ( itr . hasNext ( ) ) { sb . append ( delimiter ) ; sb . append ... | Join a collection of strings together into one . | 112 | 9 |
42,999 | public static boolean isJsonObject ( final String s ) { if ( s == null || s . isEmpty ( ) ) { return false ; } if ( s . startsWith ( "{" ) || s . startsWith ( "[" ) || "true" . equals ( s ) || "false" . equals ( s ) || "null" . equals ( s ) || decimalPattern . matcher ( s ) . matches ( ) ) { return true ; } return fals... | Check if a given string is a JSON object . | 100 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.