idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
32,800 | public String get ( int idx ) { if ( idx < 0 || idx >= parts . size ( ) ) { throw new IndexOutOfBoundsException ( ) ; } return parts . get ( idx ) ; } | the specifiled part of the request uri |
32,801 | private PathEntry getPathEntry ( UriEntry uri ) { PathEntry pathEntry = new PathEntry ( ContextRouter . MAP_PATH_TYPE , "default" ) ; int length = uri . getLength ( ) ; if ( length < 2 ) return pathEntry ; String requestUri = uri . getRequestUri ( ) ; String last_str = uri . get ( length - 1 ) ; if ( last_str . equals ... | get the final key with specified path |
32,802 | private void resizeTo ( int length ) { if ( length <= 0 ) throw new IllegalArgumentException ( "length <= 0" ) ; if ( length != buff . length ) { int len = ( length > buff . length ) ? buff . length : length ; char [ ] obuff = buff ; buff = new char [ length ] ; System . arraycopy ( obuff , 0 , buff , 0 , len ) ; } } | resize the buffer this will have to copy the old chars from the old buffer to the new buffer |
32,803 | public IStringBuffer append ( String str ) { if ( str == null ) throw new NullPointerException ( ) ; if ( count + str . length ( ) > buff . length ) { resizeTo ( ( count + str . length ( ) ) * 2 + 1 ) ; } for ( int j = 0 ; j < str . length ( ) ; j ++ ) { buff [ count ++ ] = str . charAt ( j ) ; } return this ; } | append a string to the buffer |
32,804 | public IStringBuffer append ( char [ ] chars , int start , int length ) { if ( chars == null ) throw new NullPointerException ( ) ; if ( start < 0 ) throw new IndexOutOfBoundsException ( ) ; if ( length <= 0 ) throw new IndexOutOfBoundsException ( ) ; if ( start + length > chars . length ) throw new IndexOutOfBoundsExc... | append parts of the chars to the buffer |
32,805 | public IStringBuffer append ( char [ ] chars , int start ) { append ( chars , start , chars . length - start ) ; return this ; } | append the rest of the chars to the buffer |
32,806 | public IStringBuffer append ( char c ) { if ( count == buff . length ) { resizeTo ( buff . length * 2 + 1 ) ; } buff [ count ++ ] = c ; return this ; } | append a char to the buffer |
32,807 | public char charAt ( int idx ) { if ( idx < 0 ) throw new IndexOutOfBoundsException ( "idx{" + idx + "} < 0" ) ; if ( idx >= count ) throw new IndexOutOfBoundsException ( "idx{" + idx + "} >= buffer.length" ) ; return buff [ idx ] ; } | get the char at a specified position in the buffer |
32,808 | public IStringBuffer deleteCharAt ( int idx ) { if ( idx < 0 ) throw new IndexOutOfBoundsException ( "idx < 0" ) ; if ( idx >= count ) throw new IndexOutOfBoundsException ( "idx >= buffer.length" ) ; for ( int j = idx ; j < count - 1 ; j ++ ) { buff [ j ] = buff [ j + 1 ] ; } count -- ; return this ; } | delete the char at the specified position |
32,809 | public void set ( int idx , char chr ) { if ( idx < 0 ) throw new IndexOutOfBoundsException ( "idx < 0" ) ; if ( idx >= count ) throw new IndexOutOfBoundsException ( "idx >= buffer.length" ) ; buff [ idx ] = chr ; } | set the char at the specified index |
32,810 | protected IWord getNextTimeMergedWord ( IWord word , int eIdx ) throws IOException { int pIdx = TimeUtil . getDateTimeIndex ( word . getEntity ( eIdx ) ) ; if ( pIdx == TimeUtil . DATETIME_NONE ) { return null ; } IWord [ ] wMask = TimeUtil . createDateTimePool ( ) ; TimeUtil . fillDateTimePool ( wMask , pIdx , word ) ... | get and return the next time merged date - time word |
32,811 | protected IWord getNextDatetimeWord ( IWord word , int entityIdx ) throws IOException { IWord dWord = super . next ( ) ; if ( dWord == null ) { return null ; } String [ ] entity = dWord . getEntity ( ) ; if ( entity == null ) { eWordPool . add ( dWord ) ; return null ; } int eIdx = 0 ; if ( ( eIdx = ArrayUtil . startsW... | get and return the next date - time word |
32,812 | private IWord getNumericUnitComposedWord ( String numeric , IWord unitWord ) { IStringBuffer sb = new IStringBuffer ( ) ; sb . clear ( ) . append ( numeric ) . append ( unitWord . getValue ( ) ) ; IWord wd = new Word ( sb . toString ( ) , IWord . T_CJK_WORD ) ; String [ ] entity = unitWord . getEntity ( ) ; int eIdx = ... | internal method to define the composed entity for numeric and unit word composed word |
32,813 | public List < Issue > getIssuesBySummary ( String projectKey , String summaryField ) throws RedmineException { if ( ( projectKey != null ) && ( projectKey . length ( ) > 0 ) ) { return transport . getObjectsList ( Issue . class , new BasicNameValuePair ( "subject" , summaryField ) , new BasicNameValuePair ( "project_id... | There could be several issues with the same summary so the method returns List . |
32,814 | public List < SavedQuery > getSavedQueries ( String projectKey ) throws RedmineException { Set < NameValuePair > params = new HashSet < > ( ) ; if ( ( projectKey != null ) && ( projectKey . length ( ) > 0 ) ) { params . add ( new BasicNameValuePair ( "project_id" , projectKey ) ) ; } return transport . getObjectsList (... | Get saved queries for the given project available to the current user . |
32,815 | public static < T > void addIfNotNull ( JSONWriter writer , String field , T value , JsonObjectWriter < T > objWriter ) throws JSONException { if ( value == null ) return ; writer . key ( field ) ; writer . object ( ) ; objWriter . write ( writer , value ) ; writer . endObject ( ) ; } | Adds an object if object is not null . |
32,816 | public static < T > void addScalarArray ( JSONWriter writer , String field , Collection < T > items , JsonObjectWriter < T > objWriter ) throws JSONException { writer . key ( field ) ; writer . array ( ) ; for ( T item : items ) { objWriter . write ( writer , item ) ; } writer . endArray ( ) ; } | Adds a list of scalar values . |
32,817 | public URI addAPIKey ( String uri ) { try { final URIBuilder builder = new URIBuilder ( uri ) ; if ( apiAccessKey != null ) { builder . setParameter ( "key" , apiAccessKey ) ; } return builder . build ( ) ; } catch ( URISyntaxException e ) { throw new RedmineInternalError ( e ) ; } } | Adds API key to URI if the key is specified |
32,818 | public static SSLSocketFactory createSocketFactory ( Collection < KeyStore > extraStores ) throws KeyStoreException , KeyManagementException { final Collection < X509TrustManager > managers = new ArrayList < > ( ) ; for ( KeyStore ks : extraStores ) { addX509Managers ( managers , ks ) ; } addX509Managers ( managers , n... | Creates a new SSL socket factory which supports both system - installed keys and all additional keys in the provided keystores . |
32,819 | private static void addX509Managers ( final Collection < X509TrustManager > managers , KeyStore ks ) throws KeyStoreException , Error { try { final TrustManagerFactory tmf = TrustManagerFactory . getInstance ( TrustManagerFactory . getDefaultAlgorithm ( ) ) ; tmf . init ( ks ) ; for ( TrustManager tm : tmf . getTrustMa... | Adds X509 keystore - backed trust manager into the list of managers . |
32,820 | public < T > T addObject ( T object , NameValuePair ... params ) throws RedmineException { final EntityConfig < T > config = getConfig ( object . getClass ( ) ) ; if ( config . writer == null ) { throw new RuntimeException ( "can't create object: writer is not implemented or is not registered in RedmineJSONBuilder for ... | Performs an add object request . |
32,821 | public < T > void deleteChildId ( Class < ? > parentClass , String parentId , T object , Integer value ) throws RedmineException { URI uri = getURIConfigurator ( ) . getChildIdURI ( parentClass , parentId , object . getClass ( ) , value ) ; HttpDelete httpDelete = new HttpDelete ( uri ) ; String response = send ( httpD... | Performs delete child Id request . |
32,822 | public < T extends Identifiable > void deleteObject ( Class < T > classs , String id ) throws RedmineException { final URI uri = getURIConfigurator ( ) . getObjectURI ( classs , id ) ; final HttpDelete http = new HttpDelete ( uri ) ; send ( http ) ; } | Deletes an object . |
32,823 | public < R > R download ( String uri , ContentHandler < BasicHttpResponse , R > handler ) throws RedmineException { final URI requestUri = configurator . addAPIKey ( uri ) ; final HttpGet request = new HttpGet ( requestUri ) ; if ( onBehalfOfUser != null ) { request . addHeader ( "X-Redmine-Switch-User" , onBehalfOfUse... | Downloads redmine content . |
32,824 | public < T > T getChildEntry ( Class < ? > parentClass , String parentId , Class < T > classs , String childId , NameValuePair ... params ) throws RedmineException { final EntityConfig < T > config = getConfig ( classs ) ; final URI uri = getURIConfigurator ( ) . getChildIdURI ( parentClass , parentId , classs , childI... | Delivers a single child entry by its identifier . |
32,825 | public Project addTrackers ( Collection < Tracker > trackers ) { if ( ! storage . isPropertySet ( TRACKERS ) ) storage . set ( TRACKERS , new HashSet < > ( ) ) ; storage . get ( TRACKERS ) . addAll ( trackers ) ; return this ; } | Adds the specified trackers to this project . If this project is created or updated on the redmine server each tracker id must be a valid tracker on the server . |
32,826 | public static RedmineManager createUnauthenticated ( String uri , HttpClient httpClient ) { return createWithUserAuth ( uri , null , null , httpClient ) ; } | Creates a non - authenticating redmine manager . |
32,827 | public static RedmineManager createWithUserAuth ( String uri , String login , String password ) { return createWithUserAuth ( uri , login , password , createDefaultHttpClient ( uri ) ) ; } | Creates a new RedmineManager with user - based authentication . |
32,828 | public static RedmineManager createWithUserAuth ( String uri , String login , String password , HttpClient httpClient ) { final Transport transport = new Transport ( new URIConfigurator ( uri , null ) , httpClient ) ; transport . setCredentials ( login , password ) ; return new RedmineManager ( transport ) ; } | Creates a new redmine managen with user - based authentication . |
32,829 | public void update ( ) throws RedmineException { String urlSafeTitle = getUrlSafeString ( getTitle ( ) ) ; transport . updateChildEntry ( Project . class , getProjectKey ( ) , this , urlSafeTitle ) ; } | projectKey must be set before calling this . Version must be set to the latest version of the document . |
32,830 | private InputStream decodeStream ( String encoding , InputStream initialStream ) throws IOException { if ( encoding == null ) return initialStream ; if ( "gzip" . equals ( encoding ) ) return new GZIPInputStream ( initialStream ) ; if ( "deflate" . equals ( encoding ) ) return new InflaterInputStream ( initialStream ) ... | Decodes a transport stream . |
32,831 | public static void updateCollections ( PropertyStorage storage , Transport transport ) { storage . getProperties ( ) . forEach ( e -> { if ( Collection . class . isAssignableFrom ( e . getKey ( ) . getType ( ) ) ) { ( ( Collection ) e . getValue ( ) ) . forEach ( i -> { if ( i instanceof FluentStyle ) { ( ( FluentStyle... | go over all properties in the storage and set transport on FluentStyle instances inside collections if any . only process one level without recursion - to avoid potential cycles and such . |
32,832 | public static void writeProject ( JSONWriter writer , Project project ) throws IllegalArgumentException , JSONException { if ( project . getName ( ) == null ) throw new IllegalArgumentException ( "Project name must be set to create a new project" ) ; if ( project . getIdentifier ( ) == null ) throw new IllegalArgumentE... | Writes a create project request . |
32,833 | public static < T > String toSimpleJSON ( String tag , T object , JsonObjectWriter < T > writer ) throws RedmineInternalError { final StringWriter swriter = new StringWriter ( ) ; final JSONWriter jsWriter = new JSONWriter ( swriter ) ; try { jsWriter . object ( ) ; jsWriter . key ( tag ) ; jsWriter . object ( ) ; writ... | Converts object to a simple json . |
32,834 | public static Router getRouter ( Class < ? extends Router > routerType ) { return routers . computeIfAbsent ( routerType , Routers :: create ) ; } | Get router instance by a given router class . The class should have a default constructor . Otherwise no router can be created |
32,835 | public Mono < Void > send ( GatewayMessage response ) { return Mono . defer ( ( ) -> outbound . sendObject ( Mono . just ( response ) . map ( codec :: encode ) . map ( TextWebSocketFrame :: new ) ) . then ( ) . doOnSuccessOrError ( ( avoid , th ) -> logSend ( response , th ) ) ) ; } | Method to send normal response . |
32,836 | public Mono < Void > onClose ( Disposable disposable ) { return Mono . create ( sink -> inbound . withConnection ( connection -> connection . onDispose ( disposable ) . onTerminate ( ) . subscribe ( sink :: success , sink :: error , sink :: success ) ) ) ; } | Lambda setter for reacting on channel close occurrence . |
32,837 | public boolean dispose ( Long streamId ) { boolean result = false ; if ( streamId != null ) { Disposable disposable = subscriptions . remove ( streamId ) ; result = disposable != null ; if ( result ) { LOGGER . debug ( "Dispose subscription by sid={}, session={}" , streamId , id ) ; disposable . dispose ( ) ; } } retur... | Disposing stored subscription by given stream id . |
32,838 | public Mono < ServiceDiscovery > start ( ) { return Mono . defer ( ( ) -> { Map < String , String > metadata = endpoint != null ? Collections . singletonMap ( endpoint . id ( ) , ClusterMetadataCodec . encodeMetadata ( endpoint ) ) : Collections . emptyMap ( ) ; ClusterConfig clusterConfig = copyFrom ( this . clusterCo... | Starts scalecube service discoevery . Joins a cluster with local services as metadata . |
32,839 | private static Class < ? > parameterizedReturnType ( Method method ) { Type type = method . getGenericReturnType ( ) ; if ( type instanceof ParameterizedType ) { try { return Class . forName ( ( ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) [ 0 ] ) . getTypeName ( ) ) ; } catch ( ClassNotFoundException e ... | extract parameterized return value of a method . |
32,840 | public void calculate ( ServiceMessage message ) { eval ( message . header ( SERVICE_RECV_TIME ) , message . header ( CLIENT_SEND_TIME ) , ( v1 , v2 ) -> clientToServiceTimer . update ( v1 - v2 , TimeUnit . MILLISECONDS ) ) ; eval ( message . header ( CLIENT_RECV_TIME ) , message . header ( SERVICE_SEND_TIME ) , ( v1 ,... | Calculates latencies by the headers into received message . |
32,841 | public static Builder from ( ServiceMessage message ) { return ServiceMessage . builder ( ) . data ( message . data ( ) ) . headers ( message . headers ( ) ) ; } | Instantiates new message with the same data and headers as at given message . |
32,842 | public static ServiceMessage error ( int errorType , int errorCode , String errorMessage ) { return ServiceMessage . builder ( ) . qualifier ( Qualifier . asError ( errorType ) ) . data ( new ErrorData ( errorCode , errorMessage ) ) . build ( ) ; } | Instantiates new message with error qualifier for given error type and specified error code and message . |
32,843 | void setHeaders ( Map < String , String > headers ) { this . headers = Collections . unmodifiableMap ( new HashMap < > ( headers ) ) ; } | Sets headers for deserialization purpose . |
32,844 | public String header ( String name ) { Objects . requireNonNull ( name ) ; return headers . get ( name ) ; } | Returns header value by given header name . |
32,845 | public boolean isError ( ) { String qualifier = qualifier ( ) ; return qualifier != null && qualifier . contains ( Qualifier . ERROR_NAMESPACE ) ; } | Describes whether the message is an error . |
32,846 | public int errorType ( ) { if ( ! isError ( ) ) { throw new IllegalStateException ( "Message is not an error" ) ; } try { return Integer . parseInt ( Qualifier . getQualifierAction ( qualifier ( ) ) ) ; } catch ( NumberFormatException e ) { throw new IllegalStateException ( "Error type must be a number" ) ; } } | Returns error type . Error type is an identifier of a group of errors . |
32,847 | public static io . scalecube . transport . Address toAddress ( io . scalecube . services . transport . api . Address address ) { return io . scalecube . transport . Address . create ( address . host ( ) , address . port ( ) ) ; } | Converts one address to another . |
32,848 | public static io . scalecube . transport . Address [ ] toAddresses ( Address [ ] addresses ) { return Arrays . stream ( addresses ) . map ( ClusterAddresses :: toAddress ) . toArray ( io . scalecube . transport . Address [ ] :: new ) ; } | Converts one address array to another address array . |
32,849 | protected final HttpServer prepareHttpServer ( LoopResources loopResources , int port , GatewayMetrics metrics ) { return HttpServer . create ( ) . tcpConfiguration ( tcpServer -> { if ( loopResources != null ) { tcpServer = tcpServer . runOn ( loopResources ) ; } if ( metrics != null ) { tcpServer = tcpServer . doOnCo... | Builds generic http server with given parameters . |
32,850 | private < T > T encodeAndTransform ( ClientMessage message , BiFunction < ByteBuf , ByteBuf , T > transformer ) throws MessageCodecException { ByteBuf dataBuffer = Unpooled . EMPTY_BUFFER ; ByteBuf headersBuffer = Unpooled . EMPTY_BUFFER ; if ( message . hasData ( ByteBuf . class ) ) { dataBuffer = message . data ( ) ;... | Encoder function . |
32,851 | public static Address from ( String hostAndPort ) { String [ ] split = hostAndPort . split ( ":" ) ; if ( split . length != 2 ) { throw new IllegalArgumentException ( ) ; } String host = split [ 0 ] ; int port = Integer . parseInt ( split [ 1 ] ) ; return new Address ( host , port ) ; } | Create address . |
32,852 | public static String asString ( String namespace , String action ) { return DELIMITER + namespace + DELIMITER + action ; } | Builds qualifier string out of given namespace and action . |
32,853 | public static String getQualifierNamespace ( String qualifierAsString ) { int pos = qualifierAsString . indexOf ( DELIMITER , 1 ) ; if ( pos == - 1 ) { throw new IllegalArgumentException ( "Wrong qualifier format: '" + qualifierAsString + "'" ) ; } return qualifierAsString . substring ( 1 , pos ) ; } | Extracts qualifier namespace part from given qualifier string . |
32,854 | public static String getQualifierAction ( String qualifierAsString ) { int pos = qualifierAsString . lastIndexOf ( DELIMITER ) ; if ( pos == - 1 ) { throw new IllegalArgumentException ( "Wrong qualifier format: '" + qualifierAsString + "'" ) ; } return qualifierAsString . substring ( pos + 1 ) ; } | Extracts qualifier action part from given qualifier string . |
32,855 | public void add ( long instrument , long orderId , Side side , long price , long size ) { if ( orders . containsKey ( orderId ) ) { return ; } OrderBook book = books . get ( instrument ) ; if ( book == null ) { return ; } Order order = new Order ( book , side , price , size ) ; boolean bbo = book . add ( side , price ,... | Add an order to an order book . |
32,856 | public void modify ( long orderId , long size ) { Order order = orders . get ( orderId ) ; if ( order == null ) { return ; } OrderBook book = order . getOrderBook ( ) ; long newSize = Math . max ( 0 , size ) ; boolean bbo = book . update ( order . getSide ( ) , order . getPrice ( ) , newSize - order . getRemainingQuant... | Modify an order in an order book . The order will retain its time priority . If the new size is zero the order is deleted from the order book . |
32,857 | public long execute ( long orderId , long quantity , long price ) { Order order = orders . get ( orderId ) ; if ( order == null ) { return 0 ; } return execute ( orderId , order , quantity , price ) ; } | Execute a quantity of an order in an order book . If the remaining quantity reaches zero the order is deleted from the order book . |
32,858 | public long cancel ( long orderId , long quantity ) { Order order = orders . get ( orderId ) ; if ( order == null ) { return 0 ; } OrderBook book = order . getOrderBook ( ) ; long remainingQuantity = order . getRemainingQuantity ( ) ; long canceledQuantity = Math . min ( quantity , remainingQuantity ) ; boolean bbo = b... | Cancel a quantity of an order in an order book . If the remaining quantity reaches zero the order is deleted from the order book . |
32,859 | public void delete ( long orderId ) { Order order = orders . get ( orderId ) ; if ( order == null ) { return ; } OrderBook book = order . getOrderBook ( ) ; boolean bbo = book . update ( order . getSide ( ) , order . getPrice ( ) , - order . getRemainingQuantity ( ) ) ; orders . remove ( orderId ) ; listener . update (... | Delete an order from an order book . |
32,860 | public static Client rsocket ( ClientSettings clientSettings ) { RSocketClientCodec clientCodec = new RSocketClientCodec ( HeadersCodec . getInstance ( clientSettings . contentType ( ) ) , DataCodec . getInstance ( clientSettings . contentType ( ) ) ) ; RSocketClientTransport clientTransport = new RSocketClientTranspor... | Client on rsocket client transport . |
32,861 | public static Client websocket ( ClientSettings clientSettings ) { WebsocketClientCodec clientCodec = new WebsocketClientCodec ( DataCodec . getInstance ( clientSettings . contentType ( ) ) ) ; WebsocketClientTransport clientTransport = new WebsocketClientTransport ( clientSettings , clientCodec , clientSettings . loop... | Client on websocket client transport . |
32,862 | public static Client http ( ClientSettings clientSettings ) { HttpClientCodec clientCodec = new HttpClientCodec ( DataCodec . getInstance ( clientSettings . contentType ( ) ) ) ; ClientTransport clientTransport = new HttpClientTransport ( clientSettings , clientCodec , clientSettings . loopResources ( ) ) ; return new ... | Client on http client transport . |
32,863 | public static void main ( String [ ] args ) throws Exception { ConfigRegistry configRegistry = ConfigBootstrap . configRegistry ( ) ; Config config = configRegistry . objectProperty ( "io.scalecube.services.examples" , Config . class ) . value ( ) . orElseThrow ( ( ) -> new IllegalStateException ( "Couldn't load config... | Main method of gateway runner . |
32,864 | public < T > Gauge < T > register ( final String component , final String methodName , final Gauge < T > gauge ) { registry . register ( MetricRegistry . name ( component , methodName ) , new Gauge < T > ( ) { public T getValue ( ) { return gauge . getValue ( ) ; } } ) ; return gauge ; } | Register a Gauge and service registry . |
32,865 | public static Timer timer ( Metrics metrics , String component , String methodName ) { if ( metrics != null ) { return metrics . getTimer ( component , methodName ) ; } else { return null ; } } | if metrics is not null returns a Timer instance for a given component and method name . |
32,866 | public static Counter counter ( Metrics metrics , String component , String methodName ) { if ( metrics != null ) { return metrics . getCounter ( component , methodName ) ; } else { return null ; } } | if metrics is not null returns a Counter instance for a given component and method name . |
32,867 | public Order add ( long orderId , long size ) { Order order = new Order ( this , orderId , size ) ; orders . add ( order ) ; return order ; } | Add a new order . |
32,868 | public long match ( long orderId , Side side , long size , EmitterProcessor < MatchOrder > matchEmmiter ) { long quantity = size ; while ( quantity > 0 && ! orders . isEmpty ( ) ) { Order order = orders . get ( 0 ) ; long orderQuantity = order . size ( ) ; if ( orderQuantity > quantity ) { order . reduce ( quantity ) ;... | Match order if possible . |
32,869 | public static DelegatedLoopResources newServerLoopResources ( EventLoopGroup workerGroup ) { EventLoopGroup bossGroup = Epoll . isAvailable ( ) ? new EpollEventLoopGroup ( BOSS_THREADS_NUM , BOSS_THREAD_FACTORY ) : new NioEventLoopGroup ( BOSS_THREADS_NUM , BOSS_THREAD_FACTORY ) ; return new DelegatedLoopResources ( bo... | Creates new loop resources for server side . |
32,870 | public boolean hasData ( Class < ? > dataClass ) { if ( dataClass == null ) { return false ; } return dataClass . isPrimitive ( ) ? hasData ( ) : dataClass . isInstance ( data ) ; } | Boolean method telling message contains data of given type or not . |
32,871 | public Collection < ServiceReference > serviceReferences ( ) { return serviceRegistrations . stream ( ) . flatMap ( sr -> sr . methods ( ) . stream ( ) . map ( sm -> new ServiceReference ( sm , sr , this ) ) ) . collect ( Collectors . toList ( ) ) ; } | Creates collection of service references from this service endpoint . |
32,872 | public Mono < Void > oneWay ( ServiceMessage request ) { return Mono . defer ( ( ) -> requestOne ( request , Void . class ) . then ( ) ) ; } | Issues fire - and - forget request . |
32,873 | public Mono < ServiceMessage > requestOne ( ServiceMessage request , Class < ? > responseType ) { return Mono . defer ( ( ) -> { String qualifier = request . qualifier ( ) ; if ( methodRegistry . containsInvoker ( qualifier ) ) { return methodRegistry . getInvoker ( request . qualifier ( ) ) . invokeOne ( request , Ser... | Issues request - and - reply request . |
32,874 | public Mono < ServiceMessage > requestOne ( ServiceMessage request , Class < ? > responseType , Address address ) { return Mono . defer ( ( ) -> { requireNonNull ( address , "requestOne address parameter is required and must not be null" ) ; requireNonNull ( transport , "transport is required and must not be null" ) ; ... | Given an address issues request - and - reply request to a remote address . |
32,875 | public Flux < ServiceMessage > requestMany ( ServiceMessage request , Class < ? > responseType ) { return Flux . defer ( ( ) -> { String qualifier = request . qualifier ( ) ; if ( methodRegistry . containsInvoker ( qualifier ) ) { return methodRegistry . getInvoker ( request . qualifier ( ) ) . invokeMany ( request , S... | Issues request to service which returns stream of service messages back . |
32,876 | public Flux < ServiceMessage > requestMany ( ServiceMessage request , Class < ? > responseType , Address address ) { return Flux . defer ( ( ) -> { requireNonNull ( address , "requestMany address parameter is required and must not be null" ) ; requireNonNull ( transport , "transport is required and must not be null" ) ... | Given an address issues request to remote service which returns stream of service messages back . |
32,877 | public Flux < ServiceMessage > requestBidirectional ( Publisher < ServiceMessage > publisher , Class < ? > responseType ) { return Flux . from ( publisher ) . switchOnFirst ( ( first , messages ) -> { if ( first . hasValue ( ) ) { ServiceMessage request = first . get ( ) ; String qualifier = request . qualifier ( ) ; i... | Issues stream of service requests to service which returns stream of service messages back . |
32,878 | public Flux < ServiceMessage > requestBidirectional ( Publisher < ServiceMessage > publisher , Class < ? > responseType , Address address ) { return Flux . defer ( ( ) -> { requireNonNull ( address , "requestBidirectional address parameter is required and must not be null" ) ; requireNonNull ( transport , "transport is... | Given an address issues stream of service requests to service which returns stream of service messages back . |
32,879 | @ SuppressWarnings ( "unchecked" ) public < T > T api ( Class < T > serviceInterface ) { final ServiceCall serviceCall = this ; final Map < Method , MethodInfo > genericReturnTypes = Reflect . methodsInfo ( serviceInterface ) ; return ( T ) Proxy . newProxyInstance ( getClass ( ) . getClassLoader ( ) , new Class [ ] { ... | Create proxy creates a java generic proxy instance by a given service interface . |
32,880 | private Optional < Object > toStringOrEqualsOrHashCode ( String method , Class < ? > serviceInterface , Object ... args ) { switch ( method ) { case "toString" : return Optional . of ( serviceInterface . toString ( ) ) ; case "equals" : return Optional . of ( serviceInterface . equals ( args [ 0 ] ) ) ; case "hashCode"... | check and handle toString or equals or hashcode method where invoked . |
32,881 | public static Microservices inject ( Microservices microservices , Collection < Object > services ) { services . forEach ( service -> Arrays . stream ( service . getClass ( ) . getDeclaredFields ( ) ) . forEach ( field -> injectField ( microservices , field , service ) ) ) ; services . forEach ( service -> processAfter... | Inject instances to the microservices instance . either Microservices or ServiceProxy . Scan all local service instances and inject a service proxy . |
32,882 | public static Type parameterizedType ( Object object ) { if ( object != null ) { Type type = object . getClass ( ) . getGenericSuperclass ( ) ; if ( type instanceof ParameterizedType ) { return ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) [ 0 ] ; } } return Object . class ; } | Util function that returns the parameterizedType of a given object . |
32,883 | public static Type parameterizedRequestType ( Method method ) { if ( method != null && method . getGenericParameterTypes ( ) . length > 0 ) { Type type = method . getGenericParameterTypes ( ) [ 0 ] ; if ( type instanceof ParameterizedType ) { return ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) [ 0 ] ; } ... | Util function that returns the parameterized of the request Type of a given object . |
32,884 | public static Collection < Class < ? > > serviceInterfaces ( Object serviceObject ) { Class < ? > [ ] interfaces = serviceObject . getClass ( ) . getInterfaces ( ) ; return Arrays . stream ( interfaces ) . filter ( interfaceClass -> interfaceClass . isAnnotationPresent ( Service . class ) ) . collect ( Collectors . toL... | Util function to get service interfaces collections from service instance . |
32,885 | public static void validateMethodOrThrow ( Method method ) { Class < ? > returnType = method . getReturnType ( ) ; if ( returnType . equals ( Void . TYPE ) ) { return ; } else if ( ! Publisher . class . isAssignableFrom ( returnType ) ) { throw new UnsupportedOperationException ( "Service method return type can be Publ... | Util function to perform basic validation of service message request . |
32,886 | public static void main ( String [ ] args ) throws InterruptedException { Microservices ms1 = Microservices . builder ( ) . discovery ( ScalecubeServiceDiscovery :: new ) . transport ( ServiceTransports :: rsocketServiceTransport ) . defaultErrorMapper ( new ServiceAProviderErrorMapper ( ) ) . services ( ServiceInfo . ... | Example runner . |
32,887 | public Mono < ServiceMessage > invokeOne ( ServiceMessage message , BiFunction < ServiceMessage , Class < ? > , ServiceMessage > dataDecoder ) { return Mono . defer ( ( ) -> Mono . from ( invoke ( toRequest ( message , dataDecoder ) ) ) ) . map ( this :: toResponse ) . onErrorResume ( throwable -> Mono . just ( errorMa... | Invokes service method with single response . |
32,888 | public Flux < ServiceMessage > invokeMany ( ServiceMessage message , BiFunction < ServiceMessage , Class < ? > , ServiceMessage > dataDecoder ) { return Flux . defer ( ( ) -> Flux . from ( invoke ( toRequest ( message , dataDecoder ) ) ) ) . map ( this :: toResponse ) . onErrorResume ( throwable -> Flux . just ( errorM... | Invokes service method with message stream response . |
32,889 | public Flux < ServiceMessage > invokeBidirectional ( Publisher < ServiceMessage > publisher , BiFunction < ServiceMessage , Class < ? > , ServiceMessage > dataDecoder ) { return Flux . from ( publisher ) . map ( message -> toRequest ( message , dataDecoder ) ) . transform ( this :: invoke ) . map ( this :: toResponse )... | Invokes service method with bidirectional communication . |
32,890 | public ServiceMessage decode ( ByteBuf dataBuffer , ByteBuf headersBuffer ) throws MessageCodecException { ServiceMessage . Builder builder = ServiceMessage . builder ( ) ; if ( dataBuffer . isReadable ( ) ) { builder . data ( dataBuffer ) ; } if ( headersBuffer . isReadable ( ) ) { try ( ByteBufInputStream stream = ne... | Decode buffers . |
32,891 | public static ServiceMessage decodeData ( ServiceMessage message , Class < ? > dataType ) throws MessageCodecException { if ( dataType == null || ! message . hasData ( ByteBuf . class ) || ( ( ByteBuf ) message . data ( ) ) . readableBytes ( ) == 0 ) { return message ; } Object data ; Class < ? > targetType = message .... | Decode message . |
32,892 | public void enter ( long orderId , Side side , long price , long size ) { if ( orders . containsKey ( orderId ) ) { return ; } if ( side == Side . BUY ) { buy ( orderId , price , size ) ; } else { sell ( orderId , price , size ) ; } } | Enter an order to this order book . |
32,893 | public void cancel ( long orderId , long size ) { Order order = orders . get ( orderId ) ; if ( order == null ) { return ; } long remainingQuantity = order . size ( ) ; if ( size >= remainingQuantity ) { return ; } if ( size > 0 ) { order . resize ( size ) ; } else { delete ( order ) ; orders . remove ( orderId ) ; } c... | Cancel a quantity of an order in this order book . The size refers to the new order size . If the new order size is set to zero the order is deleted from this order book . |
32,894 | public static < T > Optional < T > findFirst ( Class < T > clazz ) { ServiceLoader < T > load = ServiceLoader . load ( clazz ) ; return StreamSupport . stream ( load . spliterator ( ) , false ) . findFirst ( ) ; } | Finds the first implementation of the given service type and creates its instance . |
32,895 | public static < T > Optional < T > findFirst ( Class < T > clazz , Predicate < ? super T > predicate ) { ServiceLoader < T > load = ServiceLoader . load ( clazz ) ; Stream < T > stream = StreamSupport . stream ( load . spliterator ( ) , false ) ; return stream . filter ( predicate ) . findFirst ( ) ; } | Finds the first implementation of the given service type using the given predicate to filter out found service types and creates its instance . |
32,896 | public static < T > Stream < T > findAll ( Class < T > clazz ) { ServiceLoader < T > load = ServiceLoader . load ( clazz ) ; return StreamSupport . stream ( load . spliterator ( ) , false ) ; } | Finds all implementations of the given service type and creates their instances . |
32,897 | public void put ( String key , Document document ) { database . put ( key , document ) ; } | Store the supplied document and metadata at the given key . |
32,898 | public < V > V runInTransaction ( Callable < V > operation , int retryCountOnLockTimeout , String ... keysToLock ) { Transactions txns = repoEnv . getTransactions ( ) ; int retryCount = retryCountOnLockTimeout ; try { Transactions . Transaction txn = txns . begin ( ) ; if ( keysToLock . length > 0 ) { List < String > k... | Runs the given operation within a transaction after optionally locking some keys . |
32,899 | public void setStrategy ( double median , double standardDeviation , int sigma ) { this . bucketingStrategy = new StandardDeviationBucketingStrategy ( median , standardDeviation , sigma ) ; this . bucketWidth = null ; } | Set the histogram to use the standard deviation to determine the bucket sizes . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.