idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
36,500
public void doHttpFilePost ( String url , HttpResponse result , Map < String , Object > headers , File file ) { httpClient . post ( url , result , headers , file ) ; }
Performs POST to supplied url of a file as binary data .
36,501
public void doHttpFilePut ( String url , HttpResponse result , Map < String , Object > headers , File file ) { httpClient . put ( url , result , headers , file ) ; }
Performs PUT to supplied url of a file as binary data .
36,502
public void doHttpPut ( String url , String templateName , Object model , HttpResponse result ) { doHttpPut ( url , templateName , model , result , null , XmlHttpResponse . CONTENT_TYPE_XML_TEXT_UTF8 ) ; }
Performs PUT to supplied url of result of applying template with model .
36,503
public void doHttpPut ( String url , HttpResponse result , Map < String , Object > headers , String contentType ) { httpClient . put ( url , result , headers , contentType ) ; }
Performs PUT to supplied url of result s request .
36,504
public XmlHttpResponse doHttpGetXml ( String url ) { XmlHttpResponse response = new XmlHttpResponse ( ) ; doGet ( url , response ) ; setContext ( response ) ; return response ; }
GETs XML content from URL .
36,505
public void doHead ( String url , HttpResponse response , Map < String , Object > headers ) { response . setRequest ( url ) ; httpClient . head ( url , response , headers ) ; }
HEADs content from URL .
36,506
public void doDelete ( String url , HttpResponse response , Map < String , Object > headers ) { response . setRequest ( url ) ; httpClient . delete ( url , response , headers ) ; }
DELETEs content at URL .
36,507
public void doDelete ( String url , HttpResponse result , Map < String , Object > headers , String contentType ) { httpClient . delete ( url , result , headers , contentType ) ; }
Performs DELETE to supplied url of result s request .
36,508
public String getHtml ( Formatter formatter , String value ) { String result = null ; if ( value != null ) { if ( "" . equals ( value ) ) { result = "" ; } else { String formattedResponse = formatter . format ( value ) ; result = "<pre>" + StringEscapeUtils . escapeHtml4 ( formattedResponse ) + "</pre>" ; } } return re...
Formats supplied value for display as pre - formatted text in FitNesse page .
36,509
public static void handleErrorResponse ( String msg , String responseText ) { String responseHtml ; Environment instance = getInstance ( ) ; try { responseHtml = instance . getHtmlForXml ( responseText ) ; } catch ( Exception e ) { responseHtml = instance . getHtml ( value -> value , responseText ) ; } throw new FitFai...
Creates exception that will display nicely in a columnFixture .
36,510
public ProgramResponse invokeProgram ( int timeout , String directory , String command , String ... arguments ) { ProgramResponse result = new ProgramResponse ( ) ; result . setDirectory ( directory ) ; result . setCommand ( command ) ; result . setArguments ( arguments ) ; invokeProgram ( timeout , result ) ; return r...
Invokes an external program waits for it to complete and returns the result .
36,511
public String getWikiUrl ( String filePath ) { String wikiUrl = null ; String filesDir = getFitNesseFilesSectionDir ( ) ; if ( filePath . startsWith ( filesDir ) ) { String relativeFile = filePath . substring ( filesDir . length ( ) ) ; relativeFile = relativeFile . replace ( '\\' , '/' ) ; wikiUrl = "files" + relative...
Converts a file path into a relative wiki path if the path is insides the wiki s files section .
36,512
public String getFilePathFromWikiUrl ( String wikiUrl ) { String url = getHtmlCleaner ( ) . getUrl ( wikiUrl ) ; File file ; if ( url . startsWith ( "files/" ) ) { String relativeFile = url . substring ( "files" . length ( ) ) ; relativeFile = relativeFile . replace ( '/' , File . separatorChar ) ; String pathname = ge...
Gets absolute path from wiki url if file exists .
36,513
public void addSeleniumCookies ( HttpResponse response ) { CookieStore cookieStore = ensureResponseHasCookieStore ( response ) ; CookieConverter converter = getCookieConverter ( ) ; Set < Cookie > browserCookies = getSeleniumHelper ( ) . getCookies ( ) ; converter . copySeleniumCookies ( browserCookies , cookieStore ) ...
Adds Selenium cookies to response s cookie store .
36,514
public long stopTimer ( String name ) { StopWatch sw = getStopWatch ( name ) ; sw . stop ( ) ; STOP_WATCHES . remove ( name ) ; return sw . getTime ( ) ; }
Stops named timer .
36,515
public Map < String , Long > stopAllTimers ( ) { Map < String , Long > result = allTimerTimes ( ) ; STOP_WATCHES . clear ( ) ; return result ; }
Stops all running timers .
36,516
public String createContainingValue ( String filename , String key ) { Object data = value ( key ) ; if ( data == null ) { throw new SlimFixtureException ( false , "No value for key: " + key ) ; } return createContaining ( filename , data ) ; }
Creates new file containing value key .
36,517
public String encode ( String fileUrl ) { String file = getFilePathFromWikiUrl ( fileUrl ) ; try { byte [ ] content = IOUtils . toByteArray ( new FileInputStream ( file ) ) ; return base64Encode ( content ) ; } catch ( IOException e ) { throw new SlimFixtureException ( "Unable to read: " + file , e ) ; } }
Gets the content of specified file base64 encoded .
36,518
public String createFrom ( String fileName , String base64String ) { String result ; String baseName = FilenameUtils . getBaseName ( fileName ) ; String target = saveBase + baseName ; String ext = FilenameUtils . getExtension ( fileName ) ; byte [ ] content = base64Decode ( base64String ) ; String downloadedFile = File...
Creates a new file with content read from base64 encoded string .
36,519
public void addValueToIn ( Object value , String name , Map < String , Object > map ) { Object val = getValue ( map , name ) ; if ( val instanceof Collection ) { Object cleanValue = getCleanValue ( value ) ; ( ( Collection ) val ) . add ( cleanValue ) ; } else if ( val == null ) { setValueForIn ( value , name + "[0]" ,...
Adds a value to the end of a list .
36,520
public void copyValuesFromTo ( Map < String , Object > otherMap , Map < String , Object > map ) { map . putAll ( otherMap ) ; }
Adds all values in the otherMap to map .
36,521
public String applyTemplate ( String aTemplate ) { String result = getEnvironment ( ) . processTemplate ( aTemplate , getCurrentValues ( ) ) ; result = postProcess ( result ) ; result = formatResult ( aTemplate , result ) ; return result ; }
Applies template to current values .
36,522
public boolean loadValuesFrom ( String filename ) { String yamlStr = textIn ( filename ) ; Object y = yaml . load ( yamlStr ) ; if ( y instanceof Map ) { getCurrentValues ( ) . putAll ( ( Map ) y ) ; } else { getCurrentValues ( ) . put ( "elements" , y ) ; } return true ; }
Adds the yaml loaded from the specified file to current values .
36,523
public T apply ( T webElement ) { if ( firstFound == null ) { firstFound = webElement ; } return mayPass ( webElement ) ? webElement : null ; }
Filters out non - displayed elements .
36,524
private HttpEntity buildBodyWithFile ( File file ) { MultipartEntityBuilder builder = MultipartEntityBuilder . create ( ) ; builder . addBinaryBody ( "file" , file , ContentType . APPLICATION_OCTET_STREAM , file . getName ( ) ) ; HttpEntity multipart = builder . build ( ) ; return multipart ; }
Builds request body with a given file
36,525
protected static org . apache . http . client . HttpClient buildHttpClient ( boolean contentCompression , boolean sslVerification ) { RequestConfig rc = RequestConfig . custom ( ) . setCookieSpec ( CookieSpecs . STANDARD ) . build ( ) ; HttpClientBuilder builder = HttpClients . custom ( ) . useSystemProperties ( ) ; if...
Builds an apache HttpClient instance
36,526
public static < T , K , U > Collector < T , ? , LinkedHashMap < K , U > > toLinkedMap ( Function < ? super T , ? extends K > keyMapper , Function < ? super T , ? extends U > valueMapper ) { BinaryOperator < U > mergeFunction = throwingMerger ( ) ; return toLinkedMap ( keyMapper , valueMapper , mergeFunction ) ; }
Collects a stream to a LinkedHashMap each stream element is expected to produce map entry .
36,527
public static < T , K , U > Collector < T , ? , LinkedHashMap < K , U > > toLinkedMap ( Function < ? super T , ? extends K > keyMapper , Function < ? super T , ? extends U > valueMapper , BinaryOperator < U > mergeFunction ) { return Collectors . toMap ( keyMapper , valueMapper , mergeFunction , LinkedHashMap :: new ) ...
Collects a stream to a LinkedHashMap .
36,528
public static < T > BinaryOperator < T > throwingMerger ( ) { return ( u , v ) -> { throw new IllegalArgumentException ( String . format ( "Duplicate key: value %s was already present now %s is added" , u , v ) ) ; } ; }
Throws is same key is produced .
36,529
public boolean validateAgainst ( String xmlContent , String xsdContent ) { try { Source xsd = new SAXSource ( new InputSource ( new StringReader ( xsdContent ) ) ) ; Source xml = new SAXSource ( new InputSource ( new StringReader ( xmlContent ) ) ) ; SchemaFactory schemaFactory = SchemaFactory . newInstance ( XMLConsta...
Validate currently loaded xml against an xsd
36,530
public boolean loadValuesFrom ( String filename ) { String propContent = textIn ( filename ) ; PropertiesHelper propHelper = getEnvironment ( ) . getPropertiesHelper ( ) ; Properties properties = propHelper . parsePropertiesString ( propContent ) ; Map < String , Object > propAsMap = propHelper . convertPropertiesToMap...
Adds the properties loaded from the specified file to current values .
36,531
public boolean startDriver ( String driverClassName , final Map < String , Object > profile ) throws Exception { if ( OVERRIDE_ACTIVE ) { return true ; } DriverFactory driverFactory = new LocalDriverFactory ( driverClassName , profile ) ; WebDriver driver = setAndUseDriverFactory ( driverFactory ) ; return driver != nu...
Creates an instance of the specified class an injects it into SeleniumHelper so other fixtures can use it .
36,532
public boolean connectToDriverForVersionOnAt ( String browser , String version , String platformName , String url ) throws MalformedURLException { Platform platform = Platform . valueOf ( platformName ) ; DesiredCapabilities desiredCapabilities = new DesiredCapabilities ( browser , version , platform ) ; desiredCapabil...
Connects SeleniumHelper to a remote web driver .
36,533
public static Integer getFileSizeOnFTPServer ( String hostName , Integer port , String userName , String password , String filePath ) { Integer result = null ; String replyString = executeCommandOnFTPServer ( hostName , port , userName , password , "SIZE" , filePath ) ; if ( replyString == null || ! replyString . conta...
Get size of the FTP file .
36,534
public static String executeCommandOnFTPServer ( String hostName , Integer port , String userName , String password , String command , String commandArgs ) { String result = null ; if ( StringUtils . isNotBlank ( command ) ) { FTPClient ftpClient = new FTPClient ( ) ; String errorMessage = "Unable to connect and execut...
Execute command with supplied arguments on the FTP server .
36,535
public static String uploadFileToFTPServer ( String hostName , Integer port , String userName , String password , String localFileFullName , String remotePath ) { String result = null ; FTPClient ftpClient = new FTPClient ( ) ; String errorMessage = "Unable to upload file '%s' for FTP server '%s'." ; InputStream inputS...
Upload a given file to FTP server .
36,536
public static String loadFileFromFTPServer ( String hostName , Integer port , String userName , String password , String filePath , int numberOfLines ) { String result = null ; FTPClient ftpClient = new FTPClient ( ) ; InputStream inputStream = null ; String errorMessage = "Unable to connect and download file '%s' from...
Reads content of file on from FTP server to String .
36,537
public static void connectAndLoginOnFTPServer ( FTPClient ftpClient , String hostName , Integer port , String userName , String password ) { try { if ( port != null && port . intValue ( ) > 0 ) { ftpClient . connect ( hostName , port ) ; } else { ftpClient . connect ( hostName ) ; } if ( ! FTPReply . isPositiveCompleti...
Connect and login on given FTP server with provided credentials .
36,538
public static void disconnectAndLogoutFromFTPServer ( FTPClient ftpClient , String hostName ) { try { if ( ftpClient != null && ftpClient . isConnected ( ) ) { ftpClient . logout ( ) ; ftpClient . disconnect ( ) ; } } catch ( IOException e ) { throw new RuntimeException ( "Unable to logout and disconnect from : " + hos...
Disconnect and logout given FTP client .
36,539
public void addDerivedDates ( Map < String , Object > values ) { Map < String , Object > valuesToAdd = new HashMap < String , Object > ( ) ; for ( Map . Entry < String , Object > entry : values . entrySet ( ) ) { String key = entry . getKey ( ) ; Object object = entry . getValue ( ) ; if ( object != null ) { String str...
Adds derived values for dates in map .
36,540
public void setIntValueForIn ( int value , String name , Map < String , Object > map ) { setValueForIn ( Integer . valueOf ( value ) , name , map ) ; }
Stores integer value in map .
36,541
public void setDoubleValueForIn ( double value , String name , Map < String , Object > map ) { setValueForIn ( Double . valueOf ( value ) , name , map ) ; }
Stores double value in map .
36,542
public void setBooleanValueForIn ( boolean value , String name , Map < String , Object > map ) { setValueForIn ( Boolean . valueOf ( value ) , name , map ) ; }
Stores boolean value in map .
36,543
public void addValueToIn ( Object value , String name , Map < String , Object > map ) { getMapHelper ( ) . addValueToIn ( value , name , map ) ; }
Adds value to a list map .
36,544
public void copyValuesFromTo ( Map < String , Object > otherMap , Map < String , Object > map ) { getMapHelper ( ) . copyValuesFromTo ( otherMap , map ) ; }
Adds all values in the supplied map to the current values .
36,545
public String getXPath ( NamespaceContext context , String xml , String xPathExpr ) { return ( String ) evaluateXpath ( context , xml , xPathExpr , null ) ; }
Evaluates xPathExpr against xml returning single match .
36,546
public List < String > getAllXPath ( NamespaceContext context , String xml , String xPathExpr ) { List < String > result = null ; NodeList nodes = ( NodeList ) evaluateXpath ( context , xml , xPathExpr , XPathConstants . NODESET ) ; if ( nodes != null ) { result = new ArrayList < String > ( nodes . getLength ( ) ) ; fo...
Evaluates xPathExpr against xml returning all matches .
36,547
public static < T > T firstNonNull ( Supplier < T > ... suppliers ) { return firstNonNull ( Supplier :: get , suppliers ) ; }
Gets first supplier s result which is not null . Suppliers are called sequentially . Once a non - null result is obtained the remaining suppliers are not called .
36,548
public static < T , R > R firstNonNull ( T input , Function < T , R > function , Function < T , R > ... functions ) { return firstNonNull ( f -> f . apply ( input ) , Stream . concat ( Stream . of ( function ) , Stream . of ( functions ) ) ) ; }
Gets first result of set of function which is not null .
36,549
public static < T , R > R firstNonNull ( Function < T , R > function , Stream < T > values ) { return values . map ( function ) . filter ( Objects :: nonNull ) . findFirst ( ) . orElse ( null ) ; }
Gets first element which is not null .
36,550
public static XPathCheckResult parse ( String value ) { XPathCheckResult parsed = new XPathCheckResult ( ) ; parsed . result = value ; return parsed ; }
Parse method to allow Fitnesse to determine expected values .
36,551
public void addMisMatch ( String name , String expected , String actual ) { result = "NOK" ; Mismatch mismatch = new Mismatch ( ) ; mismatch . name = name ; mismatch . expected = expected ; mismatch . actual = actual ; mismatches . add ( mismatch ) ; }
Adds a mismatch to this result .
36,552
public Properties parsePropertiesString ( String propertiesAsString ) { final Properties p = new Properties ( ) ; try ( StringReader reader = new StringReader ( propertiesAsString ) ) { p . load ( reader ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Unable to parse .properties: " + propertiesAsS...
Converts String to Properties .
36,553
public Map < String , Object > convertPropertiesToMap ( Properties properties ) { return properties . entrySet ( ) . stream ( ) . collect ( toLinkedMap ( e -> e . getKey ( ) . toString ( ) , e -> e . getValue ( ) ) ) ; }
Converts Properties to Map
36,554
protected String createFile ( String dir , String fileName , byte [ ] content ) { String baseName = FilenameUtils . getBaseName ( fileName ) ; String ext = FilenameUtils . getExtension ( fileName ) ; String downloadedFile = FileUtil . saveToFile ( dir + baseName , ext , content ) ; return linkToFile ( downloadedFile ) ...
Creates a file using the supplied content .
36,555
protected String linkToFile ( File f ) { String url = getWikiUrl ( f . getAbsolutePath ( ) ) ; if ( url == null ) { url = f . toURI ( ) . toString ( ) ; } return String . format ( "<a href=\"%s\" target=\"_blank\">%s</a>" , url , f . getName ( ) ) ; }
Creates a wiki link to a file .
36,556
public void add ( String prefix , String uri ) { if ( uri == null ) { namespaces . remove ( prefix ) ; } else { if ( namespaces . containsKey ( prefix ) ) { String currentUri = namespaces . get ( prefix ) ; if ( ! currentUri . equals ( uri ) ) { throw new FitFailureException ( String . format ( "The prefix %s is alread...
Adds registration for prefix .
36,557
public String html ( String htmlSource ) { String cleanSource = htmlCleaner . cleanupPreFormatted ( htmlSource ) ; return "<div>" + StringEscapeUtils . unescapeHtml4 ( cleanSource ) + "</div>" ; }
Unescapes supplied HTML content so it can be rendered inside a wiki page .
36,558
protected String generateResultXml ( String testName , Throwable exception , double executionTime ) { int errors = 0 ; int failures = 0 ; String failureXml = "" ; if ( exception != null ) { failureXml = "<failure type=\"" + exception . getClass ( ) . getName ( ) + "\" message=\"" + getMessage ( exception ) + "\"></fail...
Creates XML string describing test outcome .
36,559
protected void writeResult ( String testName , String resultXml ) throws IOException { String finalPath = getXmlFileName ( testName ) ; Writer fw = null ; try { fw = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( finalPath ) , "UTF-8" ) ) ; fw . write ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\...
Writes XML result to disk .
36,560
public static String getData ( String dataUrl ) { int indexOfComma = dataUrl . indexOf ( ',' ) ; return dataUrl . substring ( indexOfComma + 1 ) ; }
Gets data embedded in data url .
36,561
public Object getJsonPath ( String json , String jsonPath ) { if ( ! JsonPath . isPathDefinite ( jsonPath ) ) { throw new RuntimeException ( jsonPath + " returns a list of results, not a single." ) ; } return parseJson ( json ) . read ( jsonPath ) ; }
Evaluates a JsonPath expression returning a single element .
36,562
public List < Object > getAllJsonPath ( String json , String jsonPath ) { List < Object > result ; if ( JsonPath . isPathDefinite ( jsonPath ) ) { Object val = getJsonPath ( json , jsonPath ) ; if ( val == null ) { result = Collections . emptyList ( ) ; } else { result = Collections . singletonList ( val ) ; } } else {...
Evaluates a JsonPath expression returning a multiple elements .
36,563
public String differenceBetweenAnd ( String first , String second ) { Formatter whitespaceFormatter = new Formatter ( ) { public String format ( String value ) { return ensureWhitespaceVisible ( value ) ; } } ; return getDifferencesHtml ( first , second , whitespaceFormatter ) ; }
Determines difference between two strings .
36,564
public String differenceBetweenExplicitWhitespaceAnd ( String first , String second ) { Formatter whitespaceFormatter = new Formatter ( ) { public String format ( String value ) { return explicitWhitespace ( value ) ; } } ; return getDifferencesHtml ( first , second , whitespaceFormatter ) ; }
Determines difference between two strings visualizing various forms of whitespace .
36,565
public String differenceBetweenIgnoreWhitespaceAnd ( String first , String second ) { String cleanFirst = allWhitespaceToSingleSpace ( first ) ; String cleanSecond = allWhitespaceToSingleSpace ( second ) ; String cleanDiff = differenceBetweenAnd ( cleanFirst , cleanSecond ) ; if ( cleanDiff != null ) { if ( ( "<div>" +...
Determines difference between two strings ignoring whitespace changes .
36,566
protected static void registerNs ( String prefix , String url ) { Environment . getInstance ( ) . registerNamespace ( prefix , url ) ; }
Registers a namespace in the environment so the prefix can be used in XPath expressions .
36,567
protected Response callServiceImpl ( String urlSymbolKey , String soapAction ) { String url = getSymbol ( urlSymbolKey ) . toString ( ) ; Response response = getEnvironment ( ) . createInstance ( getResponseClass ( ) ) ; callSoapService ( url , getTemplateName ( ) , soapAction , response ) ; return response ; }
Creates response calls service using configured template and current row s values and calls SOAP service .
36,568
protected XmlHttpResponse callCheckServiceImpl ( String urlSymbolKey , String soapAction ) { String url = getSymbol ( urlSymbolKey ) . toString ( ) ; XmlHttpResponse response = getEnvironment ( ) . createInstance ( getCheckResponseClass ( ) ) ; callSoapService ( url , getCheckTemplateName ( ) , soapAction , response ) ...
Creates check response calls service using configured check template and current row s values and calls SOAP service .
36,569
protected void callSoapService ( String url , String templateName , String soapAction , XmlHttpResponse response ) { Map < String , Object > headers = soapAction != null ? Collections . singletonMap ( "SOAPAction" , ( Object ) soapAction ) : null ; getEnvironment ( ) . callService ( url , templateName , getCurrentRowVa...
Calls SOAP service using template and current row s values .
36,570
public String getUrl ( String htmlLink ) { String result = htmlLink ; if ( htmlLink != null ) { Matcher linkMatcher = LINKPATTERN . matcher ( htmlLink ) ; Matcher imgMatcher = IMAGEPATTERN . matcher ( htmlLink ) ; if ( linkMatcher . matches ( ) ) { String href = linkMatcher . group ( 2 ) ; href = StringEscapeUtils . un...
Gets a URL from a wiki page value .
36,571
public static String getXPathForRowByValueInOtherColumn ( String selectIndex , String value ) { return String . format ( "/tr[td[%1$s]/descendant-or-self::text()[normalized(.)='%2$s']]" , selectIndex , value ) ; }
Creates an XPath expression - segment that will find a row selecting the row based on the text in a specific column .
36,572
public static String getXPathForColumnIndex ( String columnName ) { String headerXPath = getXPathForHeaderCellWithText ( columnName ) ; return String . format ( "count(ancestor::table[1]//tr/%1$s/preceding-sibling::th)+1" , headerXPath ) ; }
Creates an XPath expression that will determine for a row which index to use to select the cell in the column with the supplied header text value .
36,573
public static String getXPathForHeaderRowByHeaders ( String columnName , String ... extraColumnNames ) { String allHeadersPresent ; if ( extraColumnNames != null && extraColumnNames . length > 0 ) { int extraCount = extraColumnNames . length ; String [ ] columnNames = new String [ extraCount + 1 ] ; columnNames [ 0 ] =...
Creates an XPath expression that will find a header row selecting the row based on the header texts present .
36,574
private < T > T doWithLock ( LockCallback < T > callback ) throws JobPersistenceException { return doWithLock ( callback , null ) ; }
Perform Redis operations while possessing lock
36,575
private < T > T doWithLock ( LockCallback < T > callback , String errorMessage ) throws JobPersistenceException { JedisCommands jedis = null ; try { jedis = getResource ( ) ; try { storage . waitForLock ( jedis ) ; return callback . doWithLock ( jedis ) ; } catch ( ObjectAlreadyExistsException e ) { throw e ; } catch (...
Perform a redis operation while lock is acquired
36,576
public boolean lock ( T jedis ) { UUID lockId = UUID . randomUUID ( ) ; final String setResponse = jedis . set ( redisSchema . lockKey ( ) , lockId . toString ( ) , "NX" , "PX" , lockTimeout ) ; boolean lockAcquired = ! isNullOrEmpty ( setResponse ) && setResponse . equals ( "OK" ) ; if ( lockAcquired ) { lockValue = l...
Attempt to acquire a lock
36,577
public void waitForLock ( T jedis ) { while ( ! lock ( jedis ) ) { try { logger . debug ( "Waiting for Redis lock." ) ; Thread . sleep ( randomInt ( 75 , 125 ) ) ; } catch ( InterruptedException e ) { logger . error ( "Interrupted while waiting for lock." , e ) ; } } }
Attempt to acquire lock . If lock cannot be acquired wait until lock is successfully acquired .
36,578
public boolean unlock ( T jedis ) { final String currentLock = jedis . get ( redisSchema . lockKey ( ) ) ; if ( ! isNullOrEmpty ( currentLock ) && UUID . fromString ( currentLock ) . equals ( lockValue ) ) { jedis . del ( redisSchema . lockKey ( ) ) ; return true ; } return false ; }
Attempt to remove lock
36,579
public JobDetail retrieveJob ( JobKey jobKey , T jedis ) throws JobPersistenceException , ClassNotFoundException { final String jobHashKey = redisSchema . jobHashKey ( jobKey ) ; final String jobDataMapHashKey = redisSchema . jobDataMapHashKey ( jobKey ) ; final Map < String , String > jobDetailMap = jedis . hgetAll ( ...
Retrieve a job from redis
36,580
public OperableTrigger retrieveTrigger ( TriggerKey triggerKey , T jedis ) throws JobPersistenceException { final String triggerHashKey = redisSchema . triggerHashKey ( triggerKey ) ; Map < String , String > triggerMap = jedis . hgetAll ( triggerHashKey ) ; if ( triggerMap == null || triggerMap . isEmpty ( ) ) { logger...
Retrieve a trigger from Redis
36,581
public List < OperableTrigger > getTriggersForJob ( JobKey jobKey , T jedis ) throws JobPersistenceException { final String jobTriggerSetKey = redisSchema . jobTriggersSetKey ( jobKey ) ; final Set < String > triggerHashKeys = jedis . smembers ( jobTriggerSetKey ) ; List < OperableTrigger > triggers = new ArrayList < >...
Retrieve triggers associated with the given job
36,582
public boolean setTriggerState ( final RedisTriggerState state , final double score , final String triggerHashKey , T jedis ) throws JobPersistenceException { boolean success = false ; if ( state != null ) { unsetTriggerState ( triggerHashKey , jedis ) ; success = jedis . zadd ( redisSchema . triggerStateKey ( state ) ...
Set a trigger state by adding the trigger to the relevant sorted set using its next fire time as the score .
36,583
public boolean checkExists ( JobKey jobKey , T jedis ) { return jedis . exists ( redisSchema . jobHashKey ( jobKey ) ) ; }
Check if the job identified by the given key exists in storage
36,584
public boolean checkExists ( TriggerKey triggerKey , T jedis ) { return jedis . exists ( redisSchema . triggerHashKey ( triggerKey ) ) ; }
Check if the trigger identified by the given key exists
36,585
public Calendar retrieveCalendar ( String name , T jedis ) throws JobPersistenceException { final String calendarHashKey = redisSchema . calendarHashKey ( name ) ; Calendar calendar ; try { final Map < String , String > calendarMap = jedis . hgetAll ( calendarHashKey ) ; if ( calendarMap == null || calendarMap . isEmpt...
Retrieve a calendar
36,586
public void pauseJob ( JobKey jobKey , T jedis ) throws JobPersistenceException { for ( OperableTrigger trigger : getTriggersForJob ( jobKey , jedis ) ) { pauseTrigger ( trigger . getKey ( ) , jedis ) ; } }
Pause a job by pausing all of its triggers
36,587
public Set < String > getPausedTriggerGroups ( T jedis ) { final Set < String > triggerGroupSetKeys = jedis . smembers ( redisSchema . pausedTriggerGroupsSet ( ) ) ; Set < String > names = new HashSet < > ( triggerGroupSetKeys . size ( ) ) ; for ( String triggerGroupSetKey : triggerGroupSetKeys ) { names . add ( redisS...
Retrieve all currently paused trigger groups
36,588
protected boolean isActiveInstance ( String instanceId , T jedis ) { boolean isActive = ( System . currentTimeMillis ( ) - getLastInstanceActiveTime ( instanceId , jedis ) < clusterCheckInterval ) ; if ( ! isActive ) { removeLastInstanceActiveTime ( instanceId , jedis ) ; } return isActive ; }
Determine if the instance with the given id has been active in the last 4 minutes
36,589
protected void releaseOrphanedTriggers ( RedisTriggerState currentState , RedisTriggerState newState , T jedis ) throws JobPersistenceException { for ( Tuple triggerTuple : jedis . zrangeWithScores ( redisSchema . triggerStateKey ( currentState ) , 0 , - 1 ) ) { final String lockId = jedis . get ( redisSchema . trigger...
Release triggers from the given current state to the new state if its locking scheduler has not registered as alive in the last 10 minutes
36,590
protected void releaseTriggersCron ( T jedis ) throws JobPersistenceException { if ( isTriggerLockTimeoutExceeded ( jedis ) || ! isActiveInstance ( schedulerInstanceId , jedis ) ) { releaseOrphanedTriggers ( RedisTriggerState . ACQUIRED , RedisTriggerState . WAITING , jedis ) ; releaseOrphanedTriggers ( RedisTriggerSta...
Release triggers currently held by schedulers which have ceased to function
36,591
protected void settLastTriggerReleaseTime ( long time , T jedis ) { jedis . set ( redisSchema . lastTriggerReleaseTime ( ) , Long . toString ( time ) ) ; }
Set the last time at which orphaned triggers were released
36,592
protected void setLastInstanceActiveTime ( String instanceId , long time , T jedis ) { jedis . hset ( redisSchema . lastInstanceActiveTime ( ) , instanceId , Long . toString ( time ) ) ; }
Set the last time at which this instance was active
36,593
protected void removeLastInstanceActiveTime ( String instanceId , T jedis ) { jedis . hdel ( redisSchema . lastInstanceActiveTime ( ) , instanceId ) ; }
Remove the given instance from the hash
36,594
protected boolean isBlockedJob ( String jobHashKey , T jedis ) { JobKey jobKey = redisSchema . jobKey ( jobHashKey ) ; return jedis . sismember ( redisSchema . blockedJobsSet ( ) , jobHashKey ) && isActiveInstance ( jedis . get ( redisSchema . jobBlockedKey ( jobKey ) ) , jedis ) ; }
Determine if the given job is blocked by an active instance
36,595
protected boolean lockTrigger ( TriggerKey triggerKey , T jedis ) { return jedis . set ( redisSchema . triggerLockKey ( triggerKey ) , schedulerInstanceId , "NX" , "PX" , TRIGGER_LOCK_TIMEOUT ) . equals ( "OK" ) ; }
Lock the trigger with the given key to the current jobstore instance
36,596
protected List < String > split ( final String string ) { if ( null != prefix ) { return Arrays . asList ( string . substring ( prefix . length ( ) ) . split ( delimiter ) ) ; } else { return Arrays . asList ( string . split ( delimiter ) ) ; } }
Split a string on the configured delimiter
36,597
public void storeTrigger ( OperableTrigger trigger , boolean replaceExisting , JedisCluster jedis ) throws JobPersistenceException { final String triggerHashKey = redisSchema . triggerHashKey ( trigger . getKey ( ) ) ; final String triggerGroupSetKey = redisSchema . triggerGroupSetKey ( trigger . getKey ( ) ) ; final S...
Store a trigger in redis
36,598
public boolean removeJob ( JobKey jobKey , Jedis jedis ) throws JobPersistenceException { final String jobHashKey = redisSchema . jobHashKey ( jobKey ) ; final String jobBlockedKey = redisSchema . jobBlockedKey ( jobKey ) ; final String jobDataMapHashKey = redisSchema . jobDataMapHashKey ( jobKey ) ; final String jobGr...
Remove the given job from Redis
36,599
@ SuppressWarnings ( "unchecked" ) public void storeJob ( JobDetail jobDetail , boolean replaceExisting , Jedis jedis ) throws ObjectAlreadyExistsException { final String jobHashKey = redisSchema . jobHashKey ( jobDetail . getKey ( ) ) ; final String jobDataMapHashKey = redisSchema . jobDataMapHashKey ( jobDetail . get...
Store a job in Redis