idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
8,400 | private void initSocket ( ) { socket = new Socket ( ) ; try { socket . setSoLinger ( false , 0 ) ; socket . setTcpNoDelay ( true ) ; socket . setSoTimeout ( timeout ) ; } catch ( SocketException sx ) { LOGGER . error ( "Could not configure socket." , sx ) ; } } | Initializes the socket object |
8,401 | public void setTimeout ( int timeout ) { this . timeout = timeout ; try { socket . setSoTimeout ( timeout ) ; } catch ( SocketException sx ) { LOGGER . warn ( "Could not set socket timeout." , sx ) ; } } | Sets the socket timeout |
8,402 | public void open ( ) throws TTransportException { if ( isOpen ( ) ) { throw new TTransportException ( TTransportException . ALREADY_OPEN , "Socket already connected." ) ; } if ( host . length ( ) == 0 ) { throw new TTransportException ( TTransportException . NOT_OPEN , "Cannot open null host." ) ; } if ( port <= 0 ) { ... | Connects the socket creating a new socket object if necessary . |
8,403 | public ByteBuffer [ ] split ( ByteBuffer name ) { List < ByteBuffer > l = new ArrayList < ByteBuffer > ( ) ; ByteBuffer bb = name . duplicate ( ) ; readIsStatic ( bb ) ; int i = 0 ; while ( bb . remaining ( ) > 0 ) { getComparator ( i ++ , bb ) ; l . add ( ByteBufferUtil . readBytesWithShortLength ( bb ) ) ; bb . get (... | Split a composite column names into it s components . |
8,404 | public static < K extends IMeasurableMemory , V extends IMeasurableMemory > ConcurrentLinkedHashCache < K , V > create ( long weightedCapacity , EntryWeigher < K , V > entryWeiger ) { ConcurrentLinkedHashMap < K , V > map = new ConcurrentLinkedHashMap . Builder < K , V > ( ) . weigher ( entryWeiger ) . maximumWeightedC... | Initialize a cache with initial capacity with weightedCapacity |
8,405 | public void onSuccess ( StreamState state ) { logger . info ( String . format ( "[repair #%s] streaming task succeed, returning response to %s" , desc . sessionId , request . initiator ) ) ; MessagingService . instance ( ) . sendOneWay ( new SyncComplete ( desc , request . src , request . dst , true ) . createMessage (... | If we succeeded on both stream in and out reply back to the initiator . |
8,406 | public void onFailure ( Throwable t ) { MessagingService . instance ( ) . sendOneWay ( new SyncComplete ( desc , request . src , request . dst , false ) . createMessage ( ) , request . initiator ) ; } | If we failed on either stream in or out reply fail to the initiator . |
8,407 | public ByteBuffer createLocal ( long count ) { ContextState state = ContextState . allocate ( 0 , 1 , 0 ) ; state . writeLocal ( CounterId . getLocalId ( ) , 1L , count ) ; return state . context ; } | Creates a counter context with a single local shard . For use by tests of compatibility with pre - 2 . 1 counters only . |
8,408 | public ByteBuffer createRemote ( CounterId id , long clock , long count ) { ContextState state = ContextState . allocate ( 0 , 0 , 1 ) ; state . writeRemote ( id , clock , count ) ; return state . context ; } | Creates a counter context with a single remote shard . For use by tests of compatibility with pre - 2 . 1 counters only . |
8,409 | public Relationship diff ( ByteBuffer left , ByteBuffer right ) { Relationship relationship = Relationship . EQUAL ; ContextState leftState = ContextState . wrap ( left ) ; ContextState rightState = ContextState . wrap ( right ) ; while ( leftState . hasRemaining ( ) && rightState . hasRemaining ( ) ) { int compareId =... | Determine the count relationship between two contexts . |
8,410 | public long total ( ByteBuffer context ) { long total = 0L ; for ( int offset = context . position ( ) + headerLength ( context ) ; offset < context . limit ( ) ; offset += STEP_LENGTH ) total += context . getLong ( offset + CounterId . LENGTH + CLOCK_LENGTH ) ; return total ; } | Returns the aggregated count across all counter ids . |
8,411 | public static List < ? extends IResource > chain ( IResource resource ) { List < IResource > chain = new ArrayList < IResource > ( ) ; while ( true ) { chain . add ( resource ) ; if ( ! resource . hasParent ( ) ) break ; resource = resource . getParent ( ) ; } return chain ; } | Construct a chain of resource parents starting with the resource and ending with the root . |
8,412 | public void dumpInterArrivalTimes ( ) { File file = FileUtils . createTempFile ( "failuredetector-" , ".dat" ) ; OutputStream os = null ; try { os = new BufferedOutputStream ( new FileOutputStream ( file , true ) ) ; os . write ( toString ( ) . getBytes ( ) ) ; } catch ( IOException e ) { throw new FSWriteError ( e , f... | Dump the inter arrival times for examination if necessary . |
8,413 | double phi ( long tnow ) { assert arrivalIntervals . size ( ) > 0 && tLast > 0 ; long t = tnow - tLast ; return t / mean ( ) ; } | see CASSANDRA - 2597 for an explanation of the math at work here . |
8,414 | public static int pop ( long x ) { x = x - ( ( x >>> 1 ) & 0x5555555555555555L ) ; x = ( x & 0x3333333333333333L ) + ( ( x >>> 2 ) & 0x3333333333333333L ) ; x = ( x + ( x >>> 4 ) ) & 0x0F0F0F0F0F0F0F0FL ; x = x + ( x >>> 8 ) ; x = x + ( x >>> 16 ) ; x = x + ( x >>> 32 ) ; return ( ( int ) x ) & 0x7F ; } | Returns the number of bits set in the long |
8,415 | public static int ntz ( long val ) { int lower = ( int ) val ; int lowByte = lower & 0xff ; if ( lowByte != 0 ) return ntzTable [ lowByte ] ; if ( lower != 0 ) { lowByte = ( lower >>> 8 ) & 0xff ; if ( lowByte != 0 ) return ntzTable [ lowByte ] + 8 ; lowByte = ( lower >>> 16 ) & 0xff ; if ( lowByte != 0 ) return ntzTab... | Returns number of trailing zeros in a 64 bit long value . |
8,416 | public static int ntz ( int val ) { int lowByte = val & 0xff ; if ( lowByte != 0 ) return ntzTable [ lowByte ] ; lowByte = ( val >>> 8 ) & 0xff ; if ( lowByte != 0 ) return ntzTable [ lowByte ] + 8 ; lowByte = ( val >>> 16 ) & 0xff ; if ( lowByte != 0 ) return ntzTable [ lowByte ] + 16 ; return ntzTable [ val >>> 24 ] ... | Returns number of trailing zeros in a 32 bit int value . |
8,417 | public boolean intersects ( Iterable < Range < T > > ranges ) { for ( Range < T > range2 : ranges ) { if ( range2 . intersects ( this ) ) return true ; } return false ; } | return true if |
8,418 | private void warmup ( OpDistributionFactory operations ) { PrintStream warmupOutput = new PrintStream ( new OutputStream ( ) { public void write ( int b ) throws IOException { } } ) ; int iterations = 50000 * settings . node . nodes . size ( ) ; int threads = 20 ; if ( settings . rate . maxThreads > 0 ) threads = Math ... | type provided separately to support recursive call for mixed command with each command type it is performing |
8,419 | public static boolean isSuperuser ( String username ) { UntypedResultSet result = selectUser ( username ) ; return ! result . isEmpty ( ) && result . one ( ) . getBoolean ( "super" ) ; } | Checks if the user is a known superuser . |
8,420 | public static void deleteUser ( String username ) throws RequestExecutionException { QueryProcessor . process ( String . format ( "DELETE FROM %s.%s WHERE name = '%s'" , AUTH_KS , USERS_CF , escape ( username ) ) , consistencyForUser ( username ) ) ; } | Deletes the user from AUTH_KS . USERS_CF . |
8,421 | public static void setup ( ) { if ( DatabaseDescriptor . getAuthenticator ( ) instanceof AllowAllAuthenticator ) return ; setupAuthKeyspace ( ) ; setupTable ( USERS_CF , USERS_CF_SCHEMA ) ; DatabaseDescriptor . getAuthenticator ( ) . setup ( ) ; DatabaseDescriptor . getAuthorizer ( ) . setup ( ) ; MigrationManager . in... | Sets up Authenticator and Authorizer . |
8,422 | private static ConsistencyLevel consistencyForUser ( String username ) { if ( username . equals ( DEFAULT_SUPERUSER_NAME ) ) return ConsistencyLevel . QUORUM ; else return ConsistencyLevel . LOCAL_ONE ; } | Only use QUORUM cl for the default superuser . |
8,423 | public static void setupTable ( String name , String cql ) { if ( Schema . instance . getCFMetaData ( AUTH_KS , name ) == null ) { try { CFStatement parsed = ( CFStatement ) QueryProcessor . parseStatement ( cql ) ; parsed . prepareKeyspace ( AUTH_KS ) ; CreateTableStatement statement = ( CreateTableStatement ) parsed ... | Set up table from given CREATE TABLE statement under system_auth keyspace if not already done so . |
8,424 | private Multimap < Range < Token > , InetAddress > getAllRangesWithSourcesFor ( String keyspaceName , Collection < Range < Token > > desiredRanges ) { AbstractReplicationStrategy strat = Keyspace . open ( keyspaceName ) . getReplicationStrategy ( ) ; Multimap < Range < Token > , InetAddress > rangeAddresses = strat . g... | Get a map of all ranges and their respective sources that are candidates for streaming the given ranges to us . For each range the list of sources is sorted by proximity relative to the given destAddress . |
8,425 | private Multimap < Range < Token > , InetAddress > getAllRangesWithStrictSourcesFor ( String table , Collection < Range < Token > > desiredRanges ) { assert tokens != null ; AbstractReplicationStrategy strat = Keyspace . open ( table ) . getReplicationStrategy ( ) ; TokenMetadata metadataClone = metadata . cloneOnlyTok... | Get a map of all ranges and the source that will be cleaned up once this bootstrapped node is added for the given ranges . For each range the list should only contain a single source . This allows us to consistently migrate data without violating consistency . |
8,426 | Multimap < String , Map . Entry < InetAddress , Collection < Range < Token > > > > toFetch ( ) { return toFetch ; } | For testing purposes |
8,427 | private void validate ( List < ByteBuffer > variables ) throws InvalidRequestException { if ( keyValidator . size ( ) < 1 ) throw new InvalidRequestException ( "You must specify a PRIMARY KEY" ) ; else if ( keyValidator . size ( ) > 1 ) throw new InvalidRequestException ( "You may only specify one PRIMARY KEY" ) ; Abst... | Perform validation of parsed params |
8,428 | public int recover ( ) throws IOException { FilenameFilter unmanagedFilesFilter = new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { return CommitLogDescriptor . isValid ( name ) && ! instance . allocator . manages ( name ) ; } } ; for ( File file : new File ( DatabaseDescriptor . getCommitLogL... | Perform recovery on commit logs located in the directory specified by the config file . |
8,429 | public int recover ( File ... clogs ) throws IOException { CommitLogReplayer recovery = new CommitLogReplayer ( ) ; recovery . recover ( clogs ) ; return recovery . blockForWrites ( ) ; } | Perform recovery on a list of commit log files . |
8,430 | public void sync ( boolean syncAllSegments ) { CommitLogSegment current = allocator . allocatingFrom ( ) ; for ( CommitLogSegment segment : allocator . getActiveSegments ( ) ) { if ( ! syncAllSegments && segment . id > current . id ) return ; segment . sync ( ) ; } } | Forces a disk flush on the commit log files that need it . Blocking . |
8,431 | public ReplayPosition add ( Mutation mutation ) { assert mutation != null ; long size = Mutation . serializer . serializedSize ( mutation , MessagingService . current_version ) ; long totalSize = size + ENTRY_OVERHEAD_SIZE ; if ( totalSize > MAX_MUTATION_SIZE ) { throw new IllegalArgumentException ( String . format ( "... | Add a Mutation to the commit log . |
8,432 | public void discardCompletedSegments ( final UUID cfId , final ReplayPosition context ) { logger . debug ( "discard completed log segments for {}, column family {}" , context , cfId ) ; for ( Iterator < CommitLogSegment > iter = allocator . getActiveSegments ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { CommitLogSegmen... | Modifies the per - CF dirty cursors of any commit log segments for the column family according to the position given . Discards any commit log segments that are no longer used . |
8,433 | public void shutdownBlocking ( ) throws InterruptedException { executor . shutdown ( ) ; executor . awaitTermination ( ) ; allocator . shutdown ( ) ; allocator . awaitTermination ( ) ; } | Shuts down the threads used by the commit log blocking until completion . |
8,434 | public static Bounds < RowPosition > makeRowBounds ( Token left , Token right , IPartitioner partitioner ) { return new Bounds < RowPosition > ( left . minKeyBound ( partitioner ) , right . maxKeyBound ( partitioner ) , partitioner ) ; } | Compute a bounds of keys corresponding to a given bounds of token . |
8,435 | public double rankLatency ( float rank ) { if ( sample . length == 0 ) return 0 ; int index = ( int ) ( rank * sample . length ) ; if ( index >= sample . length ) index = sample . length - 1 ; return sample [ index ] * 0.000001d ; } | 0 < rank < 1 |
8,436 | private double maxScore ( List < InetAddress > endpoints ) { double maxScore = - 1.0 ; for ( InetAddress endpoint : endpoints ) { Double score = scores . get ( endpoint ) ; if ( score == null ) continue ; if ( score > maxScore ) maxScore = score ; } return maxScore ; } | Return the max score for the endpoint in the provided list or - 1 . 0 if no node have a score . |
8,437 | public static FSError findNested ( Throwable top ) { for ( Throwable t = top ; t != null ; t = t . getCause ( ) ) { if ( t instanceof FSError ) return ( FSError ) t ; } return null ; } | Unwraps the Throwable cause chain looking for an FSError instance |
8,438 | private static double hotness ( SSTableReader sstr ) { return sstr . getReadMeter ( ) == null ? 0.0 : sstr . getReadMeter ( ) . twoHourRate ( ) / sstr . estimatedKeys ( ) ; } | Returns the reads per second per key for this sstable or 0 . 0 if the sstable has no read meter |
8,439 | public static String unescapeSQLString ( String b ) { if ( b . charAt ( 0 ) == '\'' && b . charAt ( b . length ( ) - 1 ) == '\'' ) b = b . substring ( 1 , b . length ( ) - 1 ) ; return StringEscapeUtils . unescapeJava ( b ) ; } | Strips leading and trailing characters and handles and escaped characters such as \ n \ r etc . |
8,440 | public static IndexOperator getIndexOperator ( String operator ) { if ( operator . equals ( "=" ) ) { return IndexOperator . EQ ; } else if ( operator . equals ( ">=" ) ) { return IndexOperator . GTE ; } else if ( operator . equals ( ">" ) ) { return IndexOperator . GT ; } else if ( operator . equals ( "<" ) ) { return... | Returns IndexOperator from string representation |
8,441 | public static Set < String > getCfNamesByKeySpace ( KsDef keySpace ) { Set < String > names = new LinkedHashSet < String > ( ) ; for ( CfDef cfDef : keySpace . getCf_defs ( ) ) { names . add ( cfDef . getName ( ) ) ; } return names ; } | Returns set of column family names in specified keySpace . |
8,442 | public static KsDef getKeySpaceDef ( String keyspaceName , List < KsDef > keyspaces ) { keyspaceName = keyspaceName . toUpperCase ( ) ; for ( KsDef ksDef : keyspaces ) { if ( ksDef . name . toUpperCase ( ) . equals ( keyspaceName ) ) return ksDef ; } return null ; } | Parse the statement from cli and return KsDef |
8,443 | public Hlr getViewHlr ( final String hlrId ) throws GeneralException , UnauthorizedException , NotFoundException { if ( hlrId == null ) { throw new IllegalArgumentException ( "Hrl ID must be specified." ) ; } return messageBirdService . requestByID ( HLRPATH , hlrId , Hlr . class ) ; } | Retrieves the information of an existing HLR . You only need to supply the unique message id that was returned upon creation or receiving . |
8,444 | public MessageResponse sendMessage ( final Message message ) throws UnauthorizedException , GeneralException { return messageBirdService . sendPayLoad ( MESSAGESPATH , message , MessageResponse . class ) ; } | Send a message through the messagebird platform |
8,445 | public MessageResponse sendFlashMessage ( final String originator , final String body , final List < BigInteger > recipients ) throws UnauthorizedException , GeneralException { final Message message = new Message ( originator , body , recipients ) ; message . setType ( MsgType . flash ) ; return messageBirdService . se... | Convenient function to send a simple flash message to a list of recipients |
8,446 | public void deleteMessage ( final String id ) throws UnauthorizedException , GeneralException , NotFoundException { if ( id == null ) { throw new IllegalArgumentException ( "Message ID must be specified." ) ; } messageBirdService . deleteByID ( MESSAGESPATH , id ) ; } | Delete a message from the Messagebird server |
8,447 | public void deleteVoiceMessage ( final String id ) throws UnauthorizedException , GeneralException , NotFoundException { if ( id == null ) { throw new IllegalArgumentException ( "Message ID must be specified." ) ; } messageBirdService . deleteByID ( VOICEMESSAGESPATH , id ) ; } | Delete a voice message from the Messagebird server |
8,448 | public VoiceMessageList listVoiceMessages ( final Integer offset , final Integer limit ) throws UnauthorizedException , GeneralException { if ( offset != null && offset < 0 ) { throw new IllegalArgumentException ( "Offset must be > 0" ) ; } if ( limit != null && limit < 0 ) { throw new IllegalArgumentException ( "Limit... | List voice messages |
8,449 | void deleteContact ( final String id ) throws NotFoundException , GeneralException , UnauthorizedException { if ( id == null ) { throw new IllegalArgumentException ( "Contact ID must be specified." ) ; } messageBirdService . deleteByID ( CONTACTPATH , id ) ; } | Deletes an existing contact . You only need to supply the unique id that was returned upon creation . |
8,450 | public Contact sendContact ( final ContactRequest contactRequest ) throws UnauthorizedException , GeneralException { return messageBirdService . sendPayLoad ( CONTACTPATH , contactRequest , Contact . class ) ; } | Creates a new contact object . MessageBird returns the created contact object with each request . |
8,451 | public Contact updateContact ( final String id , ContactRequest contactRequest ) throws UnauthorizedException , GeneralException { if ( id == null ) { throw new IllegalArgumentException ( "Contact ID must be specified." ) ; } String request = CONTACTPATH + "/" + id ; return messageBirdService . sendPayLoad ( "PATCH" , ... | Updates an existing contact . You only need to supply the unique id that was returned upon creation . |
8,452 | public Contact viewContact ( final String id ) throws NotFoundException , GeneralException , UnauthorizedException { if ( id == null ) { throw new IllegalArgumentException ( "Contact ID must be specified." ) ; } return messageBirdService . requestByID ( CONTACTPATH , id , Contact . class ) ; } | Retrieves the information of an existing contact . You only need to supply the unique contact ID that was returned upon creation or receiving . |
8,453 | public void deleteGroup ( final String id ) throws NotFoundException , GeneralException , UnauthorizedException { if ( id == null ) { throw new IllegalArgumentException ( "Group ID must be specified." ) ; } messageBirdService . deleteByID ( GROUPPATH , id ) ; } | Deletes an existing group . You only need to supply the unique id that was returned upon creation . |
8,454 | public void deleteGroupContact ( final String groupId , final String contactId ) throws NotFoundException , GeneralException , UnauthorizedException { if ( groupId == null ) { throw new IllegalArgumentException ( "Group ID must be specified." ) ; } if ( contactId == null ) { throw new IllegalArgumentException ( "Contac... | Removes a contact from group . You need to supply the IDs of the group and contact . Does not delete the contact . |
8,455 | public Group sendGroup ( final GroupRequest groupRequest ) throws UnauthorizedException , GeneralException { return messageBirdService . sendPayLoad ( GROUPPATH , groupRequest , Group . class ) ; } | Creates a new group object . MessageBird returns the created group object with each request . |
8,456 | public void sendGroupContact ( final String groupId , final String [ ] contactIds ) throws NotFoundException , GeneralException , UnauthorizedException { String path = String . format ( "%s%s?%s" , groupId , CONTACTPATH , getQueryString ( contactIds ) ) ; messageBirdService . requestByID ( GROUPPATH , path , null ) ; } | Adds contact to group . You need to supply the IDs of the group and contact . |
8,457 | public Group updateGroup ( final String id , final GroupRequest groupRequest ) throws UnauthorizedException , GeneralException { if ( id == null ) { throw new IllegalArgumentException ( "Group ID must be specified." ) ; } String path = String . format ( "%s/%s" , GROUPPATH , id ) ; return messageBirdService . sendPayLo... | Updates an existing group . You only need to supply the unique ID that was returned upon creation . |
8,458 | public Group viewGroup ( final String id ) throws NotFoundException , GeneralException , UnauthorizedException { if ( id == null ) { throw new IllegalArgumentException ( "Group ID must be specified." ) ; } return messageBirdService . requestByID ( GROUPPATH , id , Group . class ) ; } | Retrieves the information of an existing group . You only need to supply the unique group ID that was returned upon creation or receiving . |
8,459 | public Conversation viewConversation ( final String id ) throws NotFoundException , GeneralException , UnauthorizedException { if ( id == null ) { throw new IllegalArgumentException ( "Id must be specified" ) ; } String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH ; return messageBirdService . requestByID ( url , i... | Gets a single conversation . |
8,460 | public Conversation updateConversation ( final String id , final ConversationStatus status ) throws UnauthorizedException , GeneralException { if ( id == null ) { throw new IllegalArgumentException ( "Id must be specified." ) ; } String url = String . format ( "%s%s/%s" , CONVERSATIONS_BASE_URL , CONVERSATION_PATH , id... | Updates a conversation . |
8,461 | public ConversationList listConversations ( final int offset , final int limit ) throws UnauthorizedException , GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH ; return messageBirdService . requestList ( url , offset , limit , ConversationList . class ) ; } | Gets a Conversation listing with specified pagination options . |
8,462 | public Conversation startConversation ( ConversationStartRequest request ) throws UnauthorizedException , GeneralException { String url = String . format ( "%s%s/start" , CONVERSATIONS_BASE_URL , CONVERSATION_PATH ) ; return messageBirdService . sendPayLoad ( url , request , Conversation . class ) ; } | Starts a conversation by sending an initial message . |
8,463 | public ConversationMessageList listConversationMessages ( final String conversationId , final int offset , final int limit ) throws UnauthorizedException , GeneralException { String url = String . format ( "%s%s/%s%s" , CONVERSATIONS_BASE_URL , CONVERSATION_PATH , conversationId , CONVERSATION_MESSAGE_PATH ) ; return m... | Gets a ConversationMessage listing with specified pagination options . |
8,464 | public ConversationMessageList listConversationMessages ( final String conversationId ) throws UnauthorizedException , GeneralException { final int offset = 0 ; final int limit = 10 ; return listConversationMessages ( conversationId , offset , limit ) ; } | Gets a ConversationMessage listing with default pagination options . |
8,465 | public ConversationMessage viewConversationMessage ( final String messageId ) throws NotFoundException , GeneralException , UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_MESSAGE_PATH ; return messageBirdService . requestByID ( url , messageId , ConversationMessage . class ) ; } | Gets a single message . |
8,466 | public ConversationMessage sendConversationMessage ( final String conversationId , final ConversationMessageRequest request ) throws UnauthorizedException , GeneralException { String url = String . format ( "%s%s/%s%s" , CONVERSATIONS_BASE_URL , CONVERSATION_PATH , conversationId , CONVERSATION_MESSAGE_PATH ) ; return ... | Sends a message to an existing Conversation . |
8,467 | public void deleteConversationWebhook ( final String webhookId ) throws NotFoundException , GeneralException , UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH ; messageBirdService . deleteByID ( url , webhookId ) ; } | Deletes a webhook . |
8,468 | public ConversationWebhook sendConversationWebhook ( final ConversationWebhookRequest request ) throws UnauthorizedException , GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH ; return messageBirdService . sendPayLoad ( url , request , ConversationWebhook . class ) ; } | Creates a new webhook . |
8,469 | public ConversationWebhook viewConversationWebhook ( final String webhookId ) throws NotFoundException , GeneralException , UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH ; return messageBirdService . requestByID ( url , webhookId , ConversationWebhook . class ) ; } | Gets a single webhook . |
8,470 | ConversationWebhookList listConversationWebhooks ( final int offset , final int limit ) throws UnauthorizedException , GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH ; return messageBirdService . requestList ( url , offset , limit , ConversationWebhookList . class ) ; } | Gets a ConversationWebhook listing with the specified pagination options . |
8,471 | public VoiceCallResponse sendVoiceCall ( final VoiceCall voiceCall ) throws UnauthorizedException , GeneralException { if ( voiceCall . getSource ( ) == null ) { throw new IllegalArgumentException ( "Source of voice call must be specified." ) ; } if ( voiceCall . getDestination ( ) == null ) { throw new IllegalArgument... | Function for voice call to a number |
8,472 | public VoiceCallResponseList listAllVoiceCalls ( Integer page , Integer pageSize ) throws GeneralException , UnauthorizedException { String url = String . format ( "%s%s" , VOICE_CALLS_BASE_URL , VOICECALLSPATH ) ; return messageBirdService . requestList ( url , new PagedPaging ( page , pageSize ) , VoiceCallResponseLi... | Function to list all voice calls |
8,473 | public VoiceCallResponse viewVoiceCall ( final String id ) throws NotFoundException , GeneralException , UnauthorizedException { if ( id == null ) { throw new IllegalArgumentException ( "Voice Message ID must be specified." ) ; } String url = String . format ( "%s%s" , VOICE_CALLS_BASE_URL , VOICECALLSPATH ) ; return m... | Function to view voice call by id |
8,474 | public void deleteVoiceCall ( final String id ) throws NotFoundException , GeneralException , UnauthorizedException { if ( id == null ) { throw new IllegalArgumentException ( "Voice Message ID must be specified." ) ; } String url = String . format ( "%s%s" , VOICE_CALLS_BASE_URL , VOICECALLSPATH ) ; messageBirdService ... | Function to delete voice call by id |
8,475 | public VoiceCallLegResponse viewCallLegsByCallId ( String callId , Integer page , Integer pageSize ) throws UnsupportedEncodingException , UnauthorizedException , GeneralException { if ( callId == null ) { throw new IllegalArgumentException ( "Voice call ID must be specified." ) ; } String url = String . format ( "%s%s... | Retrieves a listing of all legs . |
8,476 | public VoiceCallLeg viewCallLegByCallIdAndLegId ( final String callId , String legId ) throws UnsupportedEncodingException , NotFoundException , GeneralException , UnauthorizedException { if ( callId == null ) { throw new IllegalArgumentException ( "Voice call ID must be specified." ) ; } if ( legId == null ) { throw n... | Retrieves a leg resource . The parameters are the unique ID of the call and of the leg that were returned upon their respective creation . |
8,477 | public WebhookResponseData createWebHook ( Webhook webhook ) throws UnauthorizedException , GeneralException { if ( webhook . getTitle ( ) == null ) { throw new IllegalArgumentException ( "Title of webhook must be specified." ) ; } if ( webhook . getUrl ( ) == null ) { throw new IllegalArgumentException ( "URL of webho... | Function to create web hook |
8,478 | public WebhookResponseData viewWebHook ( String id ) throws NotFoundException , GeneralException , UnauthorizedException { if ( id == null ) { throw new IllegalArgumentException ( "Id of webHook must be specified." ) ; } String url = String . format ( "%s%s" , VOICE_CALLS_BASE_URL , WEBHOOKS ) ; return messageBirdServi... | Function to view webhook |
8,479 | private byte [ ] computeSignature ( Request request ) { String timestampAndQuery = request . getTimestamp ( ) + '\n' + request . getSortedQueryParameters ( ) + '\n' ; byte [ ] timestampAndQueryBytes = timestampAndQuery . getBytes ( CHARSET_UTF8 ) ; byte [ ] bodyHashBytes = getSha256Hash ( request . getData ( ) ) ; retu... | Computes the signature for a request instance . |
8,480 | private byte [ ] appendArrays ( byte [ ] first , byte [ ] second ) { byte [ ] result = new byte [ first . length + second . length ] ; System . arraycopy ( first , 0 , result , 0 , first . length ) ; System . arraycopy ( second , 0 , result , first . length , second . length ) ; return result ; } | Stitches the two arrays together and returns a new one . |
8,481 | < P > APIResponse doRequest ( final String method , final String url , final P payload ) throws GeneralException { HttpURLConnection connection = null ; InputStream inputStream = null ; if ( METHOD_PATCH . equalsIgnoreCase ( method ) ) { allowPatchRequestsIfNeeded ( ) ; } try { connection = getConnection ( url , payloa... | Actually sends a HTTP request and returns its body and HTTP status code . |
8,482 | private static String [ ] getAllowedMethods ( String [ ] existingMethods ) { int listCapacity = existingMethods . length + 1 ; List < String > allowedMethods = new ArrayList < > ( listCapacity ) ; allowedMethods . addAll ( Arrays . asList ( existingMethods ) ) ; allowedMethods . add ( METHOD_PATCH ) ; return allowedMet... | Appends PATCH to the provided array . |
8,483 | private String readToEnd ( InputStream inputStream ) { Scanner scanner = new Scanner ( inputStream ) . useDelimiter ( "\\A" ) ; return scanner . hasNext ( ) ? scanner . next ( ) : "" ; } | Reads the stream until it has no more bytes and returns a UTF - 8 encoded string representation . |
8,484 | private boolean isURLAbsolute ( String url ) { for ( String protocol : PROTOCOLS ) { if ( url . startsWith ( protocol ) ) { return true ; } } return false ; } | Attempts determining whether the provided URL is an absolute one based on the scheme . |
8,485 | public < P > HttpURLConnection getConnection ( final String serviceUrl , final P postData , final String requestType ) throws IOException { if ( requestType == null || ! REQUEST_METHODS . contains ( requestType ) ) { throw new IllegalArgumentException ( String . format ( REQUEST_METHOD_NOT_ALLOWED , requestType ) ) ; }... | Create a HttpURLConnection connection object |
8,486 | private List < ErrorReport > getErrorReportOrNull ( final String body ) { ObjectMapper objectMapper = new ObjectMapper ( ) ; try { JsonNode jsonNode = objectMapper . readValue ( body , JsonNode . class ) ; ErrorReport [ ] errors = objectMapper . readValue ( jsonNode . get ( "errors" ) . toString ( ) , ErrorReport [ ] .... | Get the MessageBird error report data . |
8,487 | private String getPathVariables ( final Map < String , Object > map ) { final StringBuilder bpath = new StringBuilder ( ) ; for ( Map . Entry < String , Object > param : map . entrySet ( ) ) { if ( bpath . length ( ) > 1 ) { bpath . append ( "&" ) ; } try { bpath . append ( URLEncoder . encode ( param . getKey ( ) , St... | Build a path variable for GET requests |
8,488 | public void setPremiumSMS ( Object shortcode , Object keyword , Object tariff , Object mid ) { final Map < String , Object > premiumSMSConfig = new LinkedHashMap < String , Object > ( 4 ) ; premiumSMSConfig . put ( "shortcode" , shortcode ) ; premiumSMSConfig . put ( "keyword" , keyword ) ; premiumSMSConfig . put ( "ta... | Setup premium SMS type |
8,489 | public static ConversationHsmLocalizableParameter defaultValue ( final String defaultValue ) { ConversationHsmLocalizableParameter parameter = new ConversationHsmLocalizableParameter ( ) ; parameter . defaultValue = defaultValue ; return parameter ; } | Gets a parameter that does a simple replacement without localization . |
8,490 | public static ConversationHsmLocalizableParameter currency ( final String defaultValue , final String code , final int amount ) { ConversationHsmLocalizableParameter parameter = new ConversationHsmLocalizableParameter ( ) ; parameter . defaultValue = defaultValue ; parameter . currency = new ConversationHsmLocalizableP... | Gets a parameter that localizes a currency . |
8,491 | public static InetAddress getInetAddress ( String hostName ) { try { return InetAddress . getByName ( hostName ) ; } catch ( UnknownHostException e ) { throw new IllegalStateException ( "Unknown host: " + e . getMessage ( ) + ". Make sure you have specified the 'GelfUDPAppender.remoteHost' property correctly in your lo... | Gets the Inet address for the GelfUDPAppender . remoteHost and gives a specialised error message if an exception is thrown |
8,492 | private Map < String , Object > mapFields ( E logEvent ) { Map < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "host" , host ) ; map . put ( "full_message" , fullMessageLayout . doLayout ( logEvent ) ) ; map . put ( "short_message" , shortMessageLayout . doLayout ( logEvent ) ) ; stackTraceF... | Creates a map of properties that represent the GELF message . |
8,493 | private void additionalFields ( Map < String , Object > map , ILoggingEvent eventObject ) { if ( useLoggerName ) { map . put ( "_loggerName" , eventObject . getLoggerName ( ) ) ; } if ( useMarker && eventHasMarker ( eventObject ) ) { map . put ( "_marker" , eventObject . getMarker ( ) . toString ( ) ) ; } if ( useThrea... | Converts the additional fields into proper GELF JSON |
8,494 | public void addAdditionalField ( String keyValue ) { String [ ] splitted = keyValue . split ( ":" ) ; if ( splitted . length != 2 ) { throw new IllegalArgumentException ( "additionalField must be of the format key:value, where key is the MDC " + "key, and value is the GELF field name. But found '" + keyValue + "' inste... | Add an additional field . This is mainly here for compatibility with logback . xml |
8,495 | public void addStaticAdditionalField ( String keyValue ) { String [ ] splitted = keyValue . split ( ":" ) ; if ( splitted . length != 2 ) { throw new IllegalArgumentException ( "staticAdditionalField must be of the format key:value, where key is the " + "additional field key (therefore should have a leading underscore)... | Add a staticAdditional field . This is mainly here for compatibility with logback . xml |
8,496 | public byte [ ] get ( ) { String timestamp = String . valueOf ( System . nanoTime ( ) ) ; byte [ ] digestString = ( hostname + timestamp ) . getBytes ( ) ; return Arrays . copyOf ( messageDigest . digest ( digestString ) , messageIdLength ) ; } | Creates a message id that should be unique on every call . The message ID needs to be unique for every message . If a message is chunked then each chunk in a message needs the same message ID . |
8,497 | public static ObjectComparatorFactory newInstance ( final String objectComparatorFactoryClassName ) throws InstantiationException , IllegalAccessException , ClassNotFoundException { return ( ObjectComparatorFactory ) Class . forName ( objectComparatorFactoryClassName ) . newInstance ( ) ; } | Create a new instance of a the specified factory class . |
8,498 | public static ObjectComparatorFactory newInstance ( final String objectComparatorFactoryClassName , final ClassLoader classLoader ) throws InstantiationException , IllegalAccessException , ClassNotFoundException { return ( ObjectComparatorFactory ) Class . forName ( objectComparatorFactoryClassName , true , classLoader... | Create a new instance of a the specified factory class by using the specified class loader . |
8,499 | public static Initializer defaultInitializer ( ) { return newInitializer ( ) . setCloseConcurrency ( 0 ) . setTestOnLogicalOpen ( false ) . setTestOnLogicalClose ( false ) . setIncompleteTransactionOnClosePolicy ( ConnectionPoolConnection . IncompleteTransactionPolicy . REPORT ) . setOpenStatementOnClosePolicy ( Connec... | Creates a segment initializer with default values . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.