idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
26,500 | public static String checkAntiCsrfToken ( HttpServletRequest request ) throws IOException , ServletException { if ( request . getContentType ( ) != null && request . getContentType ( ) . toLowerCase ( ) . indexOf ( "multipart/form-data" ) > - 1 && request . getPart ( "anti-csrf-token" ) == null || request . getParamete... | display that error message to the user . |
26,501 | public static JsonLocation expectObjectStart ( JsonParser parser ) throws IOException , JsonReadException { if ( parser . getCurrentToken ( ) != JsonToken . START_OBJECT ) { throw new JsonReadException ( "expecting the start of an object (\"{\")" , parser . getTokenLocation ( ) ) ; } JsonLocation loc = parser . getToke... | Delimiter checking helpers . |
26,502 | public static void main ( String [ ] args ) { System . out . println ( "Fastest instance is " + fastestInstance ( ) ) ; System . out . println ( "Fastest Java instance is " + fastestJavaInstance ( ) ) ; } | Prints the fastest instance . |
26,503 | private boolean nextFrameInfo ( ) throws IOException { while ( true ) { int size = 0 ; do { final int mySize = in . read ( readNumberBuff . array ( ) , size , LZ4FrameOutputStream . INTEGER_BYTES - size ) ; if ( mySize < 0 ) { return false ; } size += mySize ; } while ( size < LZ4FrameOutputStream . INTEGER_BYTES ) ; f... | Try and load in the next valid frame info . This will skip over skippable frames . |
26,504 | private static char decodeHexNibble ( final char c ) { if ( '0' <= c && c <= '9' ) { return ( char ) ( c - '0' ) ; } else if ( 'a' <= c && c <= 'f' ) { return ( char ) ( c - 'a' + 10 ) ; } else if ( 'A' <= c && c <= 'F' ) { return ( char ) ( c - 'A' + 10 ) ; } else { return Character . MAX_VALUE ; } } | Helper to decode half of a hexadecimal number from a string . |
26,505 | static < T > Middleware < SyncHandler < Response < T > > , SyncHandler < Response < T > > > exceptionMiddleware ( ) { return handler -> requestContext -> { try { return handler . invoke ( requestContext ) ; } catch ( RuntimeException e ) { return Response . forStatus ( Status . IM_A_TEAPOT ) ; } } ; } | A generic middleware that maps uncaught exceptions to error code 418 |
26,506 | private static String loadVersion ( ClassLoader classLoader ) throws IOException { try { Enumeration < URL > resources = classLoader . getResources ( "META-INF/MANIFEST.MF" ) ; while ( resources . hasMoreElements ( ) ) { final URL url = resources . nextElement ( ) ; final Manifest manifest = new Manifest ( url . openSt... | Tries to load the first Implementation - Version manifest entry it can find in the given classloader . |
26,507 | public static < T > RuleRouter < T > of ( final Iterable < Rule < T > > rules ) { return new RuleRouter < > ( ImmutableList . copyOf ( rules ) ) ; } | Create a router from a list of rules . |
26,508 | public static < T > ByteString serialize ( final String templateName , T object ) { StringWriter templateResults = new StringWriter ( ) ; try { final Template template = configuration . getTemplate ( templateName ) ; template . process ( object , templateResults ) ; } catch ( Exception e ) { throw Throwables . propagat... | Call the template engine and return the result . |
26,509 | public static < T > Middleware < AsyncHandler < T > , AsyncHandler < Response < ByteString > > > htmlSerialize ( final String templateName ) { return handler -> requestContext -> handler . invoke ( requestContext ) . thenApply ( result -> Response . forPayload ( serialize ( templateName , result ) ) . withHeader ( CONT... | Async middleware for POJO . |
26,510 | public static < T > Middleware < AsyncHandler < Response < T > > , AsyncHandler < Response < ByteString > > > htmlSerializeResponse ( final String templateName ) { return handler -> requestContext -> handler . invoke ( requestContext ) . thenApply ( response -> response . withPayload ( serialize ( templateName , respon... | Async middleware for a Response object . |
26,511 | public static < T > Middleware < SyncHandler < T > , AsyncHandler < Response < ByteString > > > htmlSerializeSync ( final String templateName ) { Middleware < SyncHandler < T > , AsyncHandler < T > > syncToAsync = Middleware :: syncToAsync ; return syncToAsync . and ( htmlSerialize ( templateName ) ) ; } | Sync middleware for POJO . |
26,512 | public static < T > Middleware < SyncHandler < Response < T > > , AsyncHandler < Response < ByteString > > > htmlSerializeResponseSync ( final String templateName ) { Middleware < SyncHandler < Response < T > > , AsyncHandler < Response < T > > > syncToAsync = Middleware :: syncToAsync ; return syncToAsync . and ( html... | Sync middleware for a Response object . |
26,513 | public static void boot ( Service service , InstanceListener instanceListener , Thread . UncaughtExceptionHandler uncaughtExceptionHandler , String ... args ) throws LoadingException { Objects . requireNonNull ( uncaughtExceptionHandler ) ; Thread . currentThread ( ) . setUncaughtExceptionHandler ( uncaughtExceptionHan... | Boot up a service and wait for it to shut down . |
26,514 | public static Middleware < AsyncHandler < ? > , AsyncHandler < Response < ? > > > replyContentType ( String contentType ) { return inner -> inner . map ( Middlewares :: ensureResponse ) . map ( response -> response . withHeader ( CONTENT_TYPE , contentType ) ) ; } | Middleware that adds the ability to set the response s Content - Type header to a defined value . |
26,515 | public static Middleware < AsyncHandler < ? > , AsyncHandler < Response < ByteString > > > serialize ( Serializer serializer ) { return inner -> inner . map ( Middlewares :: ensureResponse ) . flatMapSync ( resp -> ctx -> serializePayload ( serializer , ctx . request ( ) , resp ) ) ; } | Middleware that applies the supplied serializer to the result of the inner handler changing the payload and optionally the Content - Type header . |
26,516 | public EnvironmentFactoryBuilder withConfigResolver ( EnvironmentConfigResolver configResolver ) { checkState ( ! this . configResolver . isPresent ( ) , "Configuration resolution already set" ) ; return new EnvironmentFactoryBuilder ( backendDomain , client , closer , resolver , Optional . of ( configResolver ) ) ; } | Use custom config resolver . |
26,517 | public EnvironmentFactoryBuilder withStaticConfig ( Config configNode ) { checkState ( ! this . configResolver . isPresent ( ) , "Configuration resolution already set" ) ; return new EnvironmentFactoryBuilder ( backendDomain , client , closer , resolver , Optional . of ( new StaticConfigResolver ( configNode ) ) ) ; } | Statically inject a config object into the environment . |
26,518 | public EnvironmentFactoryBuilder withClassLoader ( ClassLoader classLoader ) { checkState ( ! this . configResolver . isPresent ( ) , "Configuration resolution already set" ) ; return new EnvironmentFactoryBuilder ( backendDomain , client , closer , resolver , Optional . of ( new LazyConfigResolver ( classLoader ) ) ) ... | Lazily load configuration from this classloader . |
26,519 | void handle ( OngoingRequest ongoingRequest , RequestContext requestContext , Endpoint endpoint ) { try { endpoint . invoke ( requestContext ) . whenComplete ( ( message , throwable ) -> { try { if ( message != null ) { ongoingRequest . reply ( message ) ; } else if ( throwable != null ) { if ( throwable instanceof Com... | Fires off the request processing asynchronously - that is this method is likely to return before the request processing finishes . |
26,520 | private Optional < DurationThresholdTracker > requestDurationThresholdTracker ( MetricId id , String endpoint ) { return durationThresholdConfig . getDurationThresholdForEndpoint ( endpoint ) . map ( threshold -> Optional . of ( new DurationThresholdTracker ( id , metricRegistry , threshold ) ) ) . orElse ( Optional . ... | Checks for endpoint - duration - goal configuration options and sets up metrics that track how many requests meet a certain duration threshold goal . |
26,521 | private void failRequests ( ) { final Set < OngoingRequest > requests = ImmutableSet . copyOf ( outstanding ) ; for ( OngoingRequest id : requests ) { final boolean removed = outstanding . remove ( id ) ; if ( removed ) { id . reply ( Response . forStatus ( Status . SERVICE_UNAVAILABLE ) ) ; } } } | Fail all outstanding requests . |
26,522 | public static < T > Single < Boolean > put ( CacheConfigBean cacheConfigBean , String key , String field , T value ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "cacheMapPut" , new JSONObject ( ) { { put ( "cacheConfig" , cacheConfigBean ) ; put ( "key" , key ) ; put ( "field" , field ) ; put ( "value... | cache map put |
26,523 | public static Single < Boolean > remove ( CacheConfigBean cacheConfigBean , String key , String field ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "cacheMapRemove" , new JSONObject ( ) { { put ( "cacheConfig" , cacheConfigBean ) ; put ( "key" , key ) ; put ( "field" , field ) ; } } ) . map ( unitResp... | remove the elements in the map |
26,524 | public static Maybe < List < String > > values ( CacheConfigBean cacheConfigBean , String key ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "cacheMapValues" , new JSONObject ( ) { { put ( "cacheConfig" , cacheConfigBean ) ; put ( "key" , key ) ; } } ) . flatMapMaybe ( unitResponse -> { unitResponse . ... | retrieval all the values in the cache list |
26,525 | public static < T > Maybe < List < T > > values ( String key , Class < T > vClazz ) { return values ( CacheService . CACHE_CONFIG_BEAN , key , vClazz ) ; } | retrieval all the values in the cache map |
26,526 | public synchronized void setBarrier ( ) throws Exception { try { client . create ( ) . creatingParentContainersIfNeeded ( ) . forPath ( barrierPath ) ; } catch ( KeeperException . NodeExistsException ignore ) { } } | Utility to set the barrier node |
26,527 | public synchronized boolean waitOnBarrier ( long maxWait , TimeUnit unit ) throws Exception { long startMs = System . currentTimeMillis ( ) ; boolean hasMaxWait = ( unit != null ) ; long maxWaitMs = hasMaxWait ? TimeUnit . MILLISECONDS . convert ( maxWait , unit ) : Long . MAX_VALUE ; boolean result ; for ( ; ; ) { res... | Blocks until the barrier no longer exists or the timeout elapses |
26,528 | public static ScheduledExecutorService newScheduledExecutor ( int corePoolSize ) { ScheduledExecutorService scheduledExecutorService = Executors . newScheduledThreadPool ( corePoolSize ) ; EXECUTORS . add ( scheduledExecutorService ) ; return scheduledExecutorService ; } | create a new xian monitored scheduled thread pool |
26,529 | public static Object luaScript ( String scripts , int keyCount , List < String > params ) { return luaScript ( CacheService . CACHE_CONFIG_BEAN , scripts , keyCount , params ) ; } | execute the lua script |
26,530 | public static Single < Object > luaScript ( CacheConfigBean cacheConfigBean , String scripts , int keyCount , List < String > params ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "cacheLua" , new JSONObject ( ) { { put ( "cacheConfig" , cacheConfigBean ) ; put ( "scripts" , scripts ) ; put ( "keyCount... | execute the specified script . |
26,531 | @ SuppressWarnings ( "unchecked" ) public static Single < Set < String > > keys ( CacheConfigBean cacheConfigBean , String pattern ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "cacheKeys" , new JSONObject ( ) { { put ( "cacheConfig" , cacheConfigBean ) ; put ( "pattern" , pattern ) ; } } ) . map ( re... | get the keys who s value matches the pattern |
26,532 | public static Single < Boolean > exists ( CacheConfigBean cacheConfigBean , String cacheKey ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "cacheExists" , new JSONObject ( ) { { put ( "cacheConfig" , cacheConfigBean ) ; put ( "key" , cacheKey ) ; } } ) . map ( unitResponse -> { unitResponse . throwExce... | check whether the key exists . |
26,533 | public static < T > Maybe < T > get ( String cacheKey , Class < T > clazz ) { return get ( CacheService . CACHE_CONFIG_BEAN , cacheKey , clazz ) ; } | get the cached object . |
26,534 | public static Single < Boolean > remove ( CacheConfigBean cacheConfigBean , String cacheKey ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "cacheObjectRemove" , new JSONObject ( ) { { put ( "cacheConfig" , cacheConfigBean ) ; put ( "key" , cacheKey ) ; } } ) . map ( unitResponseObject -> { unitResponse... | remove the cached object . |
26,535 | public static Single < Long > increment ( CacheConfigBean cacheConfigBean , String cacheKey ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "cacheIncrement" , new JSONObject ( ) { { put ( "cacheConfig" , cacheConfigBean ) ; put ( "key" , cacheKey ) ; } } ) . map ( unitResponse -> { unitResponse . throwE... | Increase the specified cache by 1 . |
26,536 | public static Single < Long > incrementByValue ( String cacheKey , long value ) { return incrementByValue ( CacheService . CACHE_CONFIG_BEAN , cacheKey , value ) ; } | increase with specified increment |
26,537 | public static String getFilteredStackTrace ( Throwable t , boolean shouldFilter ) { if ( shouldFilter ) { return getFilteredStackTrace ( t , 0 ) ; } StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw ) ; t . printStackTrace ( pw ) ; pw . close ( ) ; return sw . getBuffer ( ) . toString ( ) ;... | Get a filterered stack trace . |
26,538 | private static String tryGetForbiddenPackageName ( String classAndMethod ) { for ( String pkg : suppressedPackages ) { if ( classAndMethod . startsWith ( pkg ) ) { return pkg ; } } return null ; } | Checks to see if the class is part of a forbidden package . If so it returns the package name from the list of suppressed packages that matches otherwise it returns null . |
26,539 | private static String [ ] fmtObjectToStrArray ( Object object ) { if ( object == null ) { return null ; } if ( object instanceof String [ ] ) { return ( String [ ] ) object ; } if ( object instanceof Collection ) { Collection c = ( Collection ) object ; return ( String [ ] ) c . toArray ( new String [ c . size ( ) ] ) ... | cast or convert the given object to string array . |
26,540 | public static boolean defined ( String group ) { return LocalUnitsManager . getGroupByName ( group ) != null || ( GroupDiscovery . singleton != null && GroupDiscovery . singleton . newestDefinition ( group ) != null ) ; } | Judge whether the specified group is defined . We check local first and then remote . |
26,541 | public static boolean isDao ( String groupName ) { try { return GroupRouter . singleton . newestDefinition ( groupName ) . isDao ( ) ; } catch ( GroupUndefinedException e ) { throw new RuntimeException ( "Call GroupJudge.defined() first." , e ) ; } } | Judge whether the specified group is a dao group . |
26,542 | public UnitMeta appendDescription ( String descriptionToBeAppended ) { if ( getDescription ( ) != null ) { setDescription ( getDescription ( ) . concat ( descriptionToBeAppended ) ) ; } else { setDescription ( descriptionToBeAppended ) ; } return this ; } | Append a description string to the end of current description |
26,543 | public void forceSet ( byte [ ] newValue ) throws Exception { try { client . setData ( ) . forPath ( path , newValue ) ; } catch ( KeeperException . NoNodeException dummy ) { try { client . create ( ) . creatingParentContainersIfNeeded ( ) . forPath ( path , newValue ) ; } catch ( KeeperException . NodeExistsException ... | Forcibly sets the value any guarantees of atomicity . |
26,544 | public static Single < XianTransaction > getTransaction ( String transactionId , boolean readOnly ) { if ( BaseLocalTransaction . getExistedLocalTrans ( transactionId ) != null ) { return Single . just ( BaseLocalTransaction . getExistedLocalTrans ( transactionId ) ) ; } if ( readOnly ) { return PoolFactory . getPool (... | create or get the current xian transaction . This method is always returning a transaction reference for you . |
26,545 | private void sendToRemote ( String nodeId ) { unitRequest . getContext ( ) . setDestinationNodeId ( nodeId ) ; LocalNodeManager . sendLoadBalanced ( unitRequest , callback ) ; } | send message to remote asynchronously . |
26,546 | public List < ChildData > getCurrentData ( ) { return ImmutableList . copyOf ( Sets . < ChildData > newTreeSet ( currentData . values ( ) ) ) ; } | Return the current data . There are no guarantees of accuracy . This is merely the most recent view of the data . The data is returned in sorted order . |
26,547 | private static Single < Optional < String > > fetchAccessTokenAndReturnScope ( UnitRequest request ) { LOG . info ( "fetchAccessTokenAndReturnScope" ) ; String ip = request . getContext ( ) . getIp ( ) ; if ( StringUtil . isEmpty ( ip ) ) { throw new IllegalArgumentException ( "Client's ip is empty, please check!" ) ; ... | query for access token info and set it into the request context and return the scope of current token . |
26,548 | public static String underlineToCamel ( String param ) { if ( isEmpty ( param . trim ( ) ) ) { return "" ; } StringBuilder sb = new StringBuilder ( param ) ; Matcher mc = Pattern . compile ( UNDERLINE ) . matcher ( param ) ; int i = 0 ; while ( mc . find ( ) ) { int position = mc . end ( ) - ( i ++ ) ; sb . replace ( p... | convert underline style string to camel style . |
26,549 | public static Map < String , Object > camelToUnderline ( Map < String , Object > map ) { Map < String , Object > newMap = new HashMap < > ( ) ; for ( String key : map . keySet ( ) ) { newMap . put ( camelToUnderline ( key ) , map . get ( key ) ) ; } return newMap ; } | string keys are converted from camel style to underline style . a new map is returned the original map is not changed . |
26,550 | public static String getExceptionStacktrace ( Throwable t ) { try ( StringWriter errors = new StringWriter ( ) ) { t . printStackTrace ( new PrintWriter ( errors ) ) ; return errors . toString ( ) ; } catch ( IOException e ) { LOG . error ( e ) ; return null ; } } | get the stacktrace string . |
26,551 | public static String [ ] split ( String str , String theSplitter ) { if ( StringUtil . isEmpty ( str ) ) { return new String [ 0 ] ; } return str . trim ( ) . split ( "\\s*" + escapeSpecialChar ( theSplitter ) + "\\s*" ) ; } | split the given string into an array with the given splitter . note that all elements in the returned array are trimmed . |
26,552 | public static UnitResponse createSuccess ( Object data , String errMsg ) { return createSuccess ( data ) . setMessage ( errMsg ) ; } | create a succeeded response instance with specified data . |
26,553 | public static UnitResponse createException ( String errCode , Throwable exception ) { return UnitResponse . createException ( exception ) . setCode ( errCode ) ; } | Create an exception unit response object . |
26,554 | public static UnitResponse createError ( String errCode , Object data , String errMsg ) { if ( Group . CODE_SUCCESS . equalsIgnoreCase ( errCode ) ) { throw new IllegalArgumentException ( "Only non-success code is allowed here." ) ; } return new UnitResponse ( ) . setCode ( errCode ) . setData ( data ) . setMessage ( e... | create a new error unit response instance . |
26,555 | public static UnitResponse createTimeout ( Object dataOrException , String errMsg ) { return new UnitResponse ( ) . setCode ( Group . CODE_TIME_OUT ) . setData ( dataOrException ) . setMessage ( errMsg ) ; } | create a new timed out unit response . |
26,556 | @ SuppressWarnings ( "all" ) public static UnitResponse createRollingBack ( String errMsg ) { return UnitResponse . createUnknownError ( null , errMsg ) . setContext ( Context . create ( ) . setRollback ( true ) ) ; } | Create a rolling back response object with the given message . |
26,557 | public static UnitResponse createMissingParam ( Object theMissingParameters , String errMsg ) { return UnitResponse . createError ( Group . CODE_LACK_OF_PARAMETER , theMissingParameters , errMsg ) ; } | create a new unit response when missingParam |
26,558 | public String toJSONString ( ) { if ( context . isPretty ( ) ) { return JSON . toJSONStringWithDateFormat ( this , Constant . DATE_SERIALIZE_FORMAT , SerializerFeature . PrettyFormat ) ; } else { return JSONObject . toJSONStringWithDateFormat ( this , Constant . DATE_SERIALIZE_FORMAT ) ; } } | Standard json formation without data lost . |
26,559 | public String toVoJSONString ( boolean pretty ) { if ( pretty ) { return JSON . toJSONStringWithDateFormat ( toVoJSONObject ( ) , Constant . DATE_SERIALIZE_FORMAT , SerializerFeature . PrettyFormat ) ; } else { return JSONObject . toJSONStringWithDateFormat ( toVoJSONObject ( ) , Constant . DATE_SERIALIZE_FORMAT ) ; } ... | No matter context pretty attribute is true or not this method formats the json string you want . |
26,560 | @ SuppressWarnings ( "all" ) public JSONObject toJSONObject ( ) { try { return Reflection . toType ( this , JSONObject . class ) ; } catch ( Throwable e ) { throw new RuntimeException ( "The output cannot be converted to jsonObject!" , e ) ; } } | convert this response object into json object . |
26,561 | public void processStreamPartByPart ( String delimiterPattern , Function < String , Object > function ) { StreamUtil . partByPart ( dataToType ( InputStream . class ) , delimiterPattern , function ) ; } | Process the data InputStream Part By Part orderly . Only use this method when data of this response object is an input stream . |
26,562 | public static void copy ( UnitResponse from , UnitResponse to ) { to . setCode ( from . code ) . setData ( from . data ) . setContext ( from . context . clone ( ) ) . setMessage ( from . message ) ; } | copy all properties from one response object ot another response object . |
26,563 | public Object value ( int i , String key ) { Object data = getData ( ) ; if ( data instanceof List ) { List list = ( List ) data ; if ( list . size ( ) > 0 ) { Map map = ( Map ) list . get ( i ) ; return map . get ( key ) ; } } else if ( data instanceof Map ) { return ( ( Map ) data ) . get ( key ) ; } return null ; } | read the value of the specified index and key in this response object . |
26,564 | private void fillResponseContext ( UnitResponse . Context context ) { context . setDestinationNodeId ( unitRequest . getContext ( ) . getSourceNodeId ( ) ) ; context . setSourceNodeId ( LocalNodeManager . LOCAL_NODE_ID ) ; context . setMsgId ( unitRequest . getContext ( ) . getMsgId ( ) ) ; context . setSsid ( unitRequ... | note that context data is full - filled step by step not at once . |
26,565 | private void addAppender ( ) { final LoggerContext context = LoggerContext . getContext ( false ) ; final Configuration defaultConfig = context . getConfiguration ( ) ; String gelfInputUrl = EnvUtil . isLan ( ) ? XianConfig . get ( "gelfInputLanUrl" ) : XianConfig . get ( "gelfInputInternetUrl" ) ; System . out . print... | add the gelf - log4j2 appender into log4j2 context . |
26,566 | public void setValue ( byte [ ] newValue ) throws Exception { Preconditions . checkState ( state . get ( ) == State . STARTED , "not started" ) ; Stat result = client . setData ( ) . forPath ( path , newValue ) ; updateValue ( result . getVersion ( ) , Arrays . copyOf ( newValue , newValue . length ) ) ; } | Change the shared value value irrespective of its previous state |
26,567 | public UnitResponse get ( ) { synchronized ( responseLock ) { while ( ! isDone ( ) ) try { responseLock . wait ( ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } return unitResponse ; } } | Note this method will return right after finishing execution of the unit and before the remote handler is called . This method waits and never times out . |
26,568 | public ServiceInstance < T > build ( ) { return new ServiceInstance < T > ( name , id , address , port , sslPort , payload , registrationTimeUTC , serviceType , uriSpec , enabled ) ; } | Return a new instance with the currently set values |
26,569 | public Future < ? > scheduleWithFixedDelay ( Runnable task , long initialDelay , long delay , TimeUnit unit ) { Preconditions . checkState ( isOpen . get ( ) , "CloseableExecutorService is closed" ) ; ScheduledFuture < ? > scheduledFuture = scheduledExecutorService . scheduleWithFixedDelay ( task , initialDelay , delay... | Creates and executes a periodic action that becomes enabled first after the given initial delay and subsequently with the given delay between the termination of one execution and the commencement of the next . If any execution of the task encounters an exception subsequent executions are suppressed . Otherwise the task... |
26,570 | public static void writeMapEntry ( OutputAccessor out , String key , Object value ) { out . write ( ( byte ) '\"' ) ; if ( key == null ) out . write ( NULL ) ; else { writeUtf8 ( out , key ) ; } out . write ( Q_AND_C ) ; toJSONString ( out , value ) ; } | Write a map entry . |
26,571 | private static void toJSONString ( OutputAccessor out , Object value ) { if ( value == null ) { out . write ( NULL ) ; return ; } if ( value instanceof String ) { out . write ( ( byte ) '\"' ) ; writeUtf8 ( out , ( String ) value ) ; out . write ( ( byte ) '\"' ) ; return ; } if ( value instanceof Double ) { Double d =... | Convert an object to JSON text . Encode the value as UTF - 8 text or null if value is null or it s an NaN or an INF number . |
26,572 | private static void writeAscii ( OutputAccessor out , CharSequence seq ) { for ( int i = 0 ; i < seq . length ( ) ; i ++ ) { out . write ( ( byte ) seq . charAt ( i ) ) ; } } | Fast - Path ASCII implementation . |
26,573 | private static void writeUtf8 ( OutputAccessor out , CharSequence seq , int len ) { for ( int i = 0 ; i < len ; i ++ ) { char c = seq . charAt ( i ) ; switch ( c ) { case '\b' : out . write ( B ) ; continue ; case '\t' : out . write ( T ) ; continue ; case '\n' : out . write ( N ) ; continue ; case '\f' : out . write (... | Fast - Path UTF - 8 implementation . |
26,574 | private static void escape ( OutputAccessor out , int charToEscape ) { out . write ( '\\' ) ; out . write ( 'u' ) ; if ( charToEscape > 0xFF ) { int hi = ( charToEscape >> 8 ) & 0xFF ; out . write ( HEX_BYTES [ hi >> 4 ] ) ; out . write ( HEX_BYTES [ hi & 0xF ] ) ; charToEscape &= 0xFF ; } else { out . write ( ( byte )... | Write a UTF escape sequence using either an one or two - byte seqience . |
26,575 | public static void setMdcFields ( String spec , GelfMessageAssembler gelfMessageAssembler ) { if ( null != spec ) { String [ ] fields = spec . split ( MULTI_VALUE_DELIMITTER ) ; for ( String field : fields ) { gelfMessageAssembler . addField ( new MdcMessageField ( field . trim ( ) , field . trim ( ) ) ) ; } } } | Set the MDC fields . |
26,576 | public static void setDynamicMdcFields ( String spec , GelfMessageAssembler gelfMessageAssembler ) { if ( null != spec ) { String [ ] fields = spec . split ( MULTI_VALUE_DELIMITTER ) ; for ( String field : fields ) { gelfMessageAssembler . addField ( new DynamicMdcMessageField ( field . trim ( ) ) ) ; } } } | Set the dynamic MDC fields . |
26,577 | public static void setAdditionalFieldTypes ( String spec , GelfMessageAssembler gelfMessageAssembler ) { if ( null != spec ) { String [ ] properties = spec . split ( MULTI_VALUE_DELIMITTER ) ; for ( String field : properties ) { final int index = field . indexOf ( EQ ) ; if ( - 1 != index ) { gelfMessageAssembler . set... | Set the additional field types . |
26,578 | public void start ( ) { pen . start ( ) ; try { cache . start ( ) ; } catch ( Exception e ) { ThreadUtils . checkInterrupted ( e ) ; Throwables . propagate ( e ) ; } } | Start the group membership . Register thisId as a member and begin caching all members |
26,579 | public void setThisData ( byte [ ] data ) { try { pen . setData ( data ) ; } catch ( Exception e ) { ThreadUtils . checkInterrupted ( e ) ; Throwables . propagate ( e ) ; } } | Change the data stored in this instance s node |
26,580 | public Map < String , byte [ ] > getCurrentMembers ( ) { ImmutableMap . Builder < String , byte [ ] > builder = ImmutableMap . builder ( ) ; boolean thisIdAdded = false ; for ( ChildData data : cache . getCurrentData ( ) ) { String id = idFromPath ( data . getPath ( ) ) ; thisIdAdded = thisIdAdded || id . equals ( this... | Return the current view of membership . The keys are the IDs of the members . The values are each member s payload |
26,581 | private static RuleController getRule ( String baseUri , UnitRequest controllerRequest , TransactionalNotifyHandler handler ) { if ( ruleMap == null ) { synchronized ( LOCK_FOR_LAZY_INITIALIZATION ) { if ( ruleMap == null ) { loadRules ( ) ; } } } try { if ( ruleMap . get ( baseUri ) != null ) { Constructor < ? extends... | This method is in fact a factory method which produces the mapped rule controller . |
26,582 | static String findNode ( final List < String > children , final String path , final String protectedId ) { final String protectedPrefix = getProtectedPrefix ( protectedId ) ; String foundNode = Iterables . find ( children , new Predicate < String > ( ) { public boolean apply ( String node ) { return node . startsWith (... | Attempt to find the znode that matches the given path and protected id |
26,583 | public void addPath ( String path , Mode mode ) { PathHolder pathHolder = new PathHolder ( path , mode , 0 ) ; activePaths . put ( path , pathHolder ) ; schedule ( pathHolder , reapingThresholdMs ) ; } | Add a path to be checked by the reaper . The path will be checked periodically until the reaper is closed or until the point specified by the Mode |
26,584 | public static void error ( Object message ) { if ( level . ordinal ( ) >= Level . ERROR . ordinal ( ) ) singleton . error ( message , null , loggerName ( ) ) ; } | print error log |
26,585 | public static void error ( Throwable t ) { if ( level . ordinal ( ) >= Level . ERROR . ordinal ( ) ) singleton . error ( null , t , loggerName ( ) ) ; } | print error level log of the exception message with stacktrace . |
26,586 | public static void error ( Object errMsg , Throwable t ) { if ( level . ordinal ( ) >= Level . ERROR . ordinal ( ) ) singleton . error ( errMsg , t , loggerName ( ) ) ; } | print error level log of the the errMsg followed by the exception message with stacktrace . |
26,587 | public static void warn ( Object warnMsg ) { if ( level . ordinal ( ) >= Level . WARN . ordinal ( ) ) if ( warnMsg instanceof Throwable ) { singleton . warn ( null , ( Throwable ) warnMsg , loggerName ( ) ) ; } else { singleton . warn ( warnMsg , null , loggerName ( ) ) ; } } | print warning level log of the exception message with stacktrace . |
26,588 | public static void warn ( Object warnMsg , Throwable t ) { if ( level . ordinal ( ) >= Level . WARN . ordinal ( ) ) singleton . warn ( warnMsg , t , loggerName ( ) ) ; } | print warning level log of the the errMsg followed by the exception message with stacktrace . |
26,589 | public static void cost ( String type , long costInMilli ) { info ( new JSONObject ( ) { { put ( "type" , type ) ; put ( "cost" , costInMilli ) ; } } ) ; } | print monitoring log |
26,590 | private static String getCallerFromTheCurrentStack ( ) { StackTraceElement [ ] stes = new Throwable ( ) . getStackTrace ( ) ; for ( StackTraceElement ste : stes ) { String stackLine = ste . toString ( ) ; if ( ! stackLine . contains ( LOG . class . getName ( ) ) ) { return stackLine ; } } return stes [ stes . length - ... | getCallerFromTheCurrentStack containing full class name method name and line number of the java file name . |
26,591 | public void returnAll ( Collection < Lease > leases ) { for ( Lease l : leases ) { CloseableUtils . closeQuietly ( l ) ; } } | Convenience method . Closes all leases in the given collection of leases |
26,592 | public void commit ( ) { long elapsed = System . nanoTime ( ) - startTimeNanos ; driver . addTrace ( name , elapsed , TimeUnit . NANOSECONDS ) ; } | Record the elapsed time |
26,593 | public static Completable jedisPoolAdd ( CacheConfigBean cacheConfigBean ) { return SingleRxXian . call ( CacheService . CACHE_SERVICE , "jedisPoolAdd" , new JSONObject ( ) { { put ( "host" , cacheConfigBean . getHost ( ) ) ; put ( "port" , cacheConfigBean . getPort ( ) ) ; put ( "password" , cacheConfigBean . getPassw... | Add a cache datasource into the cache pool . |
26,594 | public static JsonInputValidator getValidator ( Class < ? > clazz ) { if ( clazz . equals ( Scope . class ) ) { return ScopeValidator . getInstance ( ) ; } if ( clazz . equals ( ApplicationInfo . class ) ) { return ApplicationInfoValidator . getInstance ( ) ; } return null ; } | Instantiates a validator depending on the class passed as a parameter . |
26,595 | public void start ( ) throws Exception { Preconditions . checkState ( state . compareAndSet ( State . LATENT , State . STARTED ) , "Cannot be started more than once" ) ; client . createContainers ( queuePath ) ; getInitialQueues ( ) ; leaderLatch . start ( ) ; service . submit ( new Callable < Void > ( ) { public Void ... | The sharder must be started |
26,596 | public T getQueue ( ) { Preconditions . checkState ( state . get ( ) == State . STARTED , "Not started" ) ; List < String > localPreferredQueues = Lists . newArrayList ( preferredQueues ) ; if ( localPreferredQueues . size ( ) > 0 ) { String key = localPreferredQueues . get ( random . nextInt ( localPreferredQueues . s... | Return one of the managed queues - the selection method cannot be relied on . It should be considered a random managed queue . |
26,597 | public static boolean shouldRetry ( int rc ) { return ( rc == KeeperException . Code . CONNECTIONLOSS . intValue ( ) ) || ( rc == KeeperException . Code . OPERATIONTIMEOUT . intValue ( ) ) || ( rc == KeeperException . Code . SESSIONMOVED . intValue ( ) ) || ( rc == KeeperException . Code . SESSIONEXPIRED . intValue ( )... | Utility - return true if the given Zookeeper result code is retry - able |
26,598 | public static boolean isRetryException ( Throwable exception ) { if ( exception instanceof KeeperException ) { KeeperException keeperException = ( KeeperException ) exception ; return shouldRetry ( keeperException . code ( ) . intValue ( ) ) ; } return false ; } | Utility - return true if the given exception is retry - able |
26,599 | public ServiceCache < T > build ( ) { if ( executorService != null ) { return new ServiceCacheImplExt < > ( discovery , name , executorService ) ; } else { return new ServiceCacheImplExt < > ( discovery , name , threadFactory ) ; } } | Return a new getGroup cache with the current settings |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.