idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
146,500
public static String decodeUrlIso ( String stringToDecode ) { try { return URLDecoder . decode ( stringToDecode , "ISO-8859-1" ) ; } catch ( UnsupportedEncodingException e1 ) { throw new RuntimeException ( e1 ) ; } }
URL - Decodes a given string using ISO - 8859 - 1 . No UnsupportedEncodingException to handle as it is dealt with in this method .
146,501
public static String ellipsize ( String text , int maxLength , String end ) { if ( text != null && text . length ( ) > maxLength ) { return text . substring ( 0 , maxLength - end . length ( ) ) + end ; } return text ; }
Cuts the string at the end if it s longer than maxLength and appends the given end string to it . The length of the resulting string is always less or equal to the given maxLength . It s valid to pass a null text ; in this case null is returned .
146,502
public static String join ( Iterable < ? > iterable , String separator ) { if ( iterable != null ) { StringBuilder buf = new StringBuilder ( ) ; Iterator < ? > it = iterable . iterator ( ) ; char singleChar = separator . length ( ) == 1 ? separator . charAt ( 0 ) : 0 ; while ( it . hasNext ( ) ) { buf . append ( it . n...
Joins the given iterable objects using the given separator into a single string .
146,503
public static String join ( int [ ] array , String separator ) { if ( array != null ) { StringBuilder buf = new StringBuilder ( Math . max ( 16 , ( separator . length ( ) + 1 ) * array . length ) ) ; char singleChar = separator . length ( ) == 1 ? separator . charAt ( 0 ) : 0 ; for ( int i = 0 ; i < array . length ; i ...
Joins the given ints using the given separator into a single string .
146,504
protected void prepareForwardedResponseHeaders ( ResponseData response ) { HttpHeaders headers = response . getHeaders ( ) ; headers . remove ( TRANSFER_ENCODING ) ; headers . remove ( CONNECTION ) ; headers . remove ( "Public-Key-Pins" ) ; headers . remove ( SERVER ) ; headers . remove ( "Strict-Transport-Security" ) ...
Remove any protocol - level headers from the remote server s response that do not apply to the new response we are sending .
146,505
protected void prepareForwardedRequestHeaders ( RequestData request , ForwardDestination destination ) { HttpHeaders headers = request . getHeaders ( ) ; headers . set ( HOST , destination . getUri ( ) . getAuthority ( ) ) ; headers . remove ( TE ) ; }
Remove any protocol - level headers from the clients request that do not apply to the new request we are sending to the remote server .
146,506
private String normalizePath ( String scriptPath ) { StringBuilder builder = new StringBuilder ( scriptPath . length ( ) + 1 ) ; if ( scriptPath . startsWith ( "/" ) ) { builder . append ( scriptPath . substring ( 1 ) ) ; } else { builder . append ( scriptPath ) ; } if ( ! scriptPath . endsWith ( "/" ) ) { builder . ap...
Ensures that every path starts and ends with a slash character .
146,507
public List < DbMigration > getMigrationsSinceVersion ( int version ) { List < DbMigration > dbMigrations = new ArrayList < > ( ) ; migrationScripts . stream ( ) . filter ( script -> script . getVersion ( ) > version ) . forEach ( script -> { String content = loadScriptContent ( script ) ; dbMigrations . add ( new DbMi...
Returns all migrations starting from and excluding the given version . Usually you want to provide the version of the database here to get all migrations that need to be executed . In case there is no script with a newer version than the one given an empty list is returned .
146,508
public int getVersion ( ) { ResultSet resultSet = session . execute ( format ( VERSION_QUERY , getTableName ( ) ) ) ; Row result = resultSet . one ( ) ; if ( result == null ) { return 0 ; } return result . getInt ( 0 ) ; }
Gets the current version of the database schema . This version is taken from the migration table and represent the latest successful entry .
146,509
private void logMigration ( DbMigration migration , boolean wasSuccessful ) { BoundStatement boundStatement = logMigrationStatement . bind ( wasSuccessful , migration . getVersion ( ) , migration . getScriptName ( ) , migration . getMigrationScript ( ) , new Date ( ) ) ; session . execute ( boundStatement ) ; }
Inserts the result of the migration into the migration table
146,510
public void migrate ( ) { if ( databaseIsUpToDate ( ) ) { LOGGER . info ( format ( "Keyspace %s is already up to date at version %d" , database . getKeyspaceName ( ) , database . getVersion ( ) ) ) ; return ; } List < DbMigration > migrations = repository . getMigrationsSinceVersion ( database . getVersion ( ) ) ; migr...
Start the actual migration . Take the version of the database get all required migrations and execute them or do nothing if the DB is already up to date .
146,511
public Set < String > findResourceNames ( String location , URI locationUri ) throws IOException { String filePath = toFilePath ( locationUri ) ; File folder = new File ( filePath ) ; if ( ! folder . isDirectory ( ) ) { LOGGER . debug ( "Skipping path as it is not a directory: " + filePath ) ; return new TreeSet < > ( ...
Scans a path on the filesystem for resources inside the given classpath location .
146,512
private Set < String > findResourceNamesFromFileSystem ( String classPathRootOnDisk , String scanRootLocation , File folder ) { LOGGER . debug ( "Scanning for resources in path: {} ({})" , folder . getPath ( ) , scanRootLocation ) ; File [ ] files = folder . listFiles ( ) ; if ( files == null ) { return emptySet ( ) ; ...
Finds all the resource names contained in this file system folder .
146,513
private String toResourceNameOnClasspath ( String classPathRootOnDisk , File file ) { String fileName = file . getAbsolutePath ( ) . replace ( "\\" , "/" ) ; return fileName . substring ( classPathRootOnDisk . length ( ) ) ; }
Converts this file into a resource name on the classpath by cutting of the file path to the classpath root .
146,514
public static < T > T notNull ( T argument , String argumentName ) { if ( argument == null ) { throw new IllegalArgumentException ( "Argument " + argumentName + " must not be null." ) ; } return argument ; }
Checks if the given argument is null and throws an exception with a message containing the argument name if that it true .
146,515
public static String notNullOrEmpty ( String argument , String argumentName ) { if ( argument == null || argument . trim ( ) . isEmpty ( ) ) { throw new IllegalArgumentException ( "Argument " + argumentName + " must not be null or empty." ) ; } return argument ; }
Checks if the given String is null or contains only whitespaces . The String is trimmed before the empty check .
146,516
public static TestSuiteResult unmarshal ( File testSuite ) throws IOException { try ( InputStream stream = new FileInputStream ( testSuite ) ) { return unmarshal ( stream ) ; } }
Unmarshal test suite from given file .
146,517
public static List < TestSuiteResult > unmarshalSuites ( File ... directories ) throws IOException { List < TestSuiteResult > results = new ArrayList < > ( ) ; List < File > files = listTestSuiteFiles ( directories ) ; for ( File file : files ) { results . add ( unmarshal ( file ) ) ; } return results ; }
Find and unmarshal all test suite files in given directories .
146,518
public static List < File > listFilesByRegex ( String regex , File ... directories ) { return listFiles ( directories , new RegexFileFilter ( regex ) , CanReadFileFilter . CAN_READ ) ; }
Returns list of files matches specified regex in specified directories
146,519
public static List < File > listFiles ( File [ ] directories , IOFileFilter fileFilter , IOFileFilter dirFilter ) { List < File > files = new ArrayList < > ( ) ; for ( File directory : directories ) { if ( ! directory . isDirectory ( ) ) { continue ; } Collection < File > filesInDirectory = FileUtils . listFiles ( dire...
Returns list of files matches filters in specified directories
146,520
private void populateAnnotations ( Collection < Annotation > annotations ) { for ( Annotation each : annotations ) { this . annotations . put ( each . annotationType ( ) , each ) ; } }
Used to populate Map with given annotations
146,521
public void setDefaults ( Annotation [ ] defaultAnnotations ) { if ( defaultAnnotations == null ) { return ; } for ( Annotation each : defaultAnnotations ) { Class < ? extends Annotation > key = each . annotationType ( ) ; if ( Title . class . equals ( key ) || Description . class . equals ( key ) ) { continue ; } if (...
Set default values for annotations . Initial annotation take precedence over the default annotation when both annotation types are present
146,522
private static String getHostname ( ) { if ( Hostname == null ) { try { Hostname = InetAddress . getLocalHost ( ) . getHostName ( ) ; } catch ( Exception e ) { Hostname = "default" ; LOGGER . warn ( "Can not get current hostname" , e ) ; } } return Hostname ; }
Save current hostname and reuse it .
146,523
public static TestCaseStartedEvent withExecutorInfo ( TestCaseStartedEvent event ) { event . getLabels ( ) . add ( createHostLabel ( getHostname ( ) ) ) ; event . getLabels ( ) . add ( createThreadLabel ( format ( "%s.%s(%s)" , ManagementFactory . getRuntimeMXBean ( ) . getName ( ) , Thread . currentThread ( ) . getNam...
Add information about host and thread to specified test case started event
146,524
private void openBrowser ( URI url ) throws IOException { if ( Desktop . isDesktopSupported ( ) ) { Desktop . getDesktop ( ) . browse ( url ) ; } else { LOGGER . error ( "Can not open browser because this capability is not supported on " + "your platform. You can use the link below to open the report manually." ) ; } }
Open the given url in default system browser .
146,525
private Server setUpServer ( ) { Server server = new Server ( port ) ; ResourceHandler handler = new ResourceHandler ( ) ; handler . setDirectoriesListed ( true ) ; handler . setWelcomeFiles ( new String [ ] { "index.html" } ) ; handler . setResourceBase ( getReportDirectoryPath ( ) . toAbsolutePath ( ) . toString ( ) ...
Set up server for report directory .
146,526
private static boolean checkModifiers ( Class < ? extends AbstractPlugin > pluginClass ) { int modifiers = pluginClass . getModifiers ( ) ; return ! Modifier . isAbstract ( modifiers ) && ! Modifier . isInterface ( modifiers ) && ! Modifier . isPrivate ( modifiers ) ; }
Check given class modifiers . Plugin with resources plugin should not be private or abstract or interface .
146,527
public void fire ( StepStartedEvent event ) { for ( LifecycleListener listener : listeners ) { try { listener . fire ( event ) ; } catch ( Exception e ) { logError ( listener , e ) ; } } }
Invoke to tell listeners that an step started event processed
146,528
private void logError ( LifecycleListener listener , Exception e ) { LOGGER . error ( "Error for listener " + listener . getClass ( ) , e ) ; }
This method log given exception in specified listener
146,529
public static String cutEnd ( String data , int maxLength ) { if ( data . length ( ) > maxLength ) { return data . substring ( 0 , maxLength ) + "..." ; } else { return data ; } }
Cut all characters from maxLength and replace it with ...
146,530
public static < T > List < T > load ( ClassLoader classLoader , Class < T > serviceType ) { List < T > foundServices = new ArrayList < > ( ) ; Iterator < T > iterator = ServiceLoader . load ( serviceType , classLoader ) . iterator ( ) ; while ( checkHasNextSafely ( iterator ) ) { try { T item = iterator . next ( ) ; fo...
Invoke to find all services for given service type using specified class loader
146,531
private static void unpackFace ( File outputDirectory ) throws IOException { ClassLoader loader = AllureMain . class . getClassLoader ( ) ; for ( ClassPath . ResourceInfo info : ClassPath . from ( loader ) . getResources ( ) ) { Matcher matcher = REPORT_RESOURCE_PATTERN . matcher ( info . getResourceName ( ) ) ; if ( m...
Unpack report face to given directory .
146,532
protected Path createTempDirectory ( String prefix ) { try { return Files . createTempDirectory ( tempDirectory , prefix ) ; } catch ( IOException e ) { throw new AllureCommandException ( e ) ; } }
Creates an temporary directory . The created directory will be deleted when command will ended .
146,533
private Level getLogLevel ( ) { return isQuiet ( ) ? Level . OFF : isVerbose ( ) ? Level . DEBUG : Level . INFO ; }
Get log level depends on provided client parameters such as verbose and quiet .
146,534
public static boolean isBadXmlCharacter ( char c ) { boolean cDataCharacter = c < '\u0020' && c != '\t' && c != '\r' && c != '\n' ; cDataCharacter |= ( c >= '\uD800' && c < '\uE000' ) ; cDataCharacter |= ( c == '\uFFFE' || c == '\uFFFF' ) ; return cDataCharacter ; }
Detect bad xml 1 . 0 characters
146,535
public static void replaceBadXmlCharactersBySpace ( char [ ] cbuf , int off , int len ) { for ( int i = off ; i < off + len ; i ++ ) { if ( isBadXmlCharacter ( cbuf [ i ] ) ) { cbuf [ i ] = '\u0020' ; } } }
Replace bad xml charactes in given array by space
146,536
public int read ( char [ ] cbuf , int off , int len ) throws IOException { int numChars = super . read ( cbuf , off , len ) ; replaceBadXmlCharactersBySpace ( cbuf , off , len ) ; return numChars ; }
Reads characters into a portion of an array then replace invalid XML characters
146,537
protected void runUnsafe ( ) throws Exception { Path reportDirectory = getReportDirectoryPath ( ) ; Files . walkFileTree ( reportDirectory , new DeleteVisitor ( ) ) ; LOGGER . info ( "Report directory <{}> was successfully cleaned." , reportDirectory ) ; }
Remove the report directory .
146,538
public static void main ( String [ ] args ) { if ( args . length < 2 ) { LOGGER . error ( "There must be at least two arguments" ) ; return ; } int lastIndex = args . length - 1 ; AllureReportGenerator reportGenerator = new AllureReportGenerator ( getFiles ( Arrays . copyOf ( args , lastIndex ) ) ) ; reportGenerator . ...
Generate Allure report data from directories with allure report results .
146,539
public static void setPropertySafely ( Marshaller marshaller , String name , Object value ) { try { marshaller . setProperty ( name , value ) ; } catch ( PropertyException e ) { LOGGER . warn ( String . format ( "Can't set \"%s\" property to given marshaller" , name ) , e ) ; } }
Try to set specified property to given marshaller
146,540
public static Attachment writeAttachmentWithErrorMessage ( Throwable throwable , String title ) { String message = throwable . getMessage ( ) ; try { return writeAttachment ( message . getBytes ( CONFIG . getAttachmentsEncoding ( ) ) , title ) ; } catch ( Exception e ) { e . addSuppressed ( throwable ) ; LOGGER . error...
Write throwable as attachment .
146,541
public static String getExtensionByMimeType ( String type ) { MimeTypes types = getDefaultMimeTypes ( ) ; try { return types . forName ( type ) . getExtension ( ) ; } catch ( Exception e ) { LOGGER . warn ( "Can't detect extension for MIME-type " + type , e ) ; return "" ; } }
Generate attachment extension from mime type
146,542
public void process ( TestCaseResult context ) { context . getParameters ( ) . add ( new Parameter ( ) . withName ( getName ( ) ) . withValue ( getValue ( ) ) . withKind ( ParameterKind . valueOf ( getKind ( ) ) ) ) ; }
Add parameter to testCase
146,543
protected void validateResultsDirectories ( ) { for ( String result : results ) { if ( Files . notExists ( Paths . get ( result ) ) ) { throw new AllureCommandException ( String . format ( "Report directory <%s> not found." , result ) ) ; } } }
Throws an exception if at least one results directory is missing .
146,544
protected String getClasspath ( ) throws IOException { List < String > classpath = new ArrayList < > ( ) ; classpath . add ( getBundleJarPath ( ) ) ; classpath . addAll ( getPluginsPath ( ) ) ; return StringUtils . toString ( classpath . toArray ( new String [ classpath . size ( ) ] ) , " " ) ; }
Returns the classpath for executable jar .
146,545
protected String getExecutableJar ( ) throws IOException { Manifest manifest = new Manifest ( ) ; manifest . getMainAttributes ( ) . put ( Attributes . Name . MANIFEST_VERSION , "1.0" ) ; manifest . getMainAttributes ( ) . put ( Attributes . Name . MAIN_CLASS , MAIN ) ; manifest . getMainAttributes ( ) . put ( Attribut...
Create an executable jar to generate the report . Created jar contains only allure configuration file .
146,546
protected String getBundleJarPath ( ) throws MalformedURLException { Path path = PROPERTIES . getAllureHome ( ) . resolve ( "app/allure-bundle.jar" ) . toAbsolutePath ( ) ; if ( Files . notExists ( path ) ) { throw new AllureCommandException ( String . format ( "Bundle not found by path <%s>" , path ) ) ; } return path...
Returns the bundle jar classpath element .
146,547
protected List < String > getPluginsPath ( ) throws IOException { List < String > result = new ArrayList < > ( ) ; Path pluginsDirectory = PROPERTIES . getAllureHome ( ) . resolve ( "plugins" ) . toAbsolutePath ( ) ; if ( Files . notExists ( pluginsDirectory ) ) { return Collections . emptyList ( ) ; } try ( DirectoryS...
Returns the plugins classpath elements .
146,548
protected String getJavaExecutablePath ( ) { String executableName = isWindows ( ) ? "bin/java.exe" : "bin/java" ; return PROPERTIES . getJavaHome ( ) . resolve ( executableName ) . toAbsolutePath ( ) . toString ( ) ; }
Returns the path to java executable .
146,549
public void run ( ) { for ( Map . Entry < String , TestSuiteResult > entry : testSuites ) { for ( TestCaseResult testCase : entry . getValue ( ) . getTestCases ( ) ) { markTestcaseAsInterruptedIfNotFinishedYet ( testCase ) ; } entry . getValue ( ) . getTestCases ( ) . add ( createFakeTestcaseWithWarning ( entry . getVa...
Mark unfinished test cases as interrupted for each unfinished test suite then write test suite result
146,550
public static void checkDirectory ( File directory ) { if ( ! ( directory . exists ( ) || directory . mkdirs ( ) ) ) { throw new ReportGenerationException ( String . format ( "Can't create data directory <%s>" , directory . getAbsolutePath ( ) ) ) ; } }
If directory doesn t exists try to create it .
146,551
public static int serialize ( final File directory , String name , Object obj ) { try ( FileOutputStream stream = new FileOutputStream ( new File ( directory , name ) ) ) { return serialize ( stream , obj ) ; } catch ( IOException e ) { throw new ReportGenerationException ( e ) ; } }
Serialize specified object to directory with specified name .
146,552
public static int serialize ( OutputStream stream , Object obj ) { ObjectMapper mapper = createMapperWithJaxbAnnotationInspector ( ) ; try ( DataOutputStream data = new DataOutputStream ( stream ) ; OutputStreamWriter writer = new OutputStreamWriter ( data , StandardCharsets . UTF_8 ) ) { mapper . writerWithDefaultPret...
Serialize specified object to directory with specified name . Given output stream will be closed .
146,553
public void process ( Step step ) { step . setName ( getName ( ) ) ; step . setStatus ( Status . PASSED ) ; step . setStart ( System . currentTimeMillis ( ) ) ; step . setTitle ( getTitle ( ) ) ; }
Sets name status start time and title to specified step
146,554
protected Deque < Step > childValue ( Deque < Step > parentValue ) { Deque < Step > queue = new LinkedList < > ( ) ; queue . add ( parentValue . getFirst ( ) ) ; return queue ; }
In case parent thread spawn thread we need create a new queue for child thread but use the only one root step . In the end all steps will be children of root step all we need is sync adding steps
146,555
public Step createRootStep ( ) { return new Step ( ) . withName ( "Root step" ) . withTitle ( "Allure step processing error: if you see this step something went wrong." ) . withStart ( System . currentTimeMillis ( ) ) . withStatus ( Status . BROKEN ) ; }
Construct new root step . Used for inspect problems with Allure lifecycle
146,556
public void process ( Step context ) { Iterator < Attachment > iterator = context . getAttachments ( ) . listIterator ( ) ; while ( iterator . hasNext ( ) ) { Attachment attachment = iterator . next ( ) ; if ( pattern . matcher ( attachment . getSource ( ) ) . matches ( ) ) { deleteAttachment ( attachment ) ; iterator ...
Remove attachments matches pattern from step and all step substeps
146,557
public void fire ( StepStartedEvent event ) { Step step = new Step ( ) ; event . process ( step ) ; stepStorage . put ( step ) ; notifier . fire ( event ) ; }
Process StepStartedEvent . New step will be created and added to stepStorage .
146,558
public void fire ( StepEvent event ) { Step step = stepStorage . getLast ( ) ; event . process ( step ) ; notifier . fire ( event ) ; }
Process any StepEvent . You can change last added to stepStorage step using this method .
146,559
public void fire ( StepFinishedEvent event ) { Step step = stepStorage . adopt ( ) ; event . process ( step ) ; notifier . fire ( event ) ; }
Process StepFinishedEvent . Change last added to stepStorage step and add it as child of previous step .
146,560
public void fire ( TestCaseStartedEvent event ) { stepStorage . get ( ) ; TestCaseResult testCase = testCaseStorage . get ( ) ; event . process ( testCase ) ; synchronized ( TEST_SUITE_ADD_CHILD_LOCK ) { testSuiteStorage . get ( event . getSuiteUid ( ) ) . getTestCases ( ) . add ( testCase ) ; } notifier . fire ( event...
Process TestCaseStartedEvent . New testCase will be created and added to suite as child .
146,561
public void fire ( TestCaseEvent event ) { TestCaseResult testCase = testCaseStorage . get ( ) ; event . process ( testCase ) ; notifier . fire ( event ) ; }
Process TestCaseEvent . You can change current testCase context using this method .
146,562
public void fire ( TestCaseFinishedEvent event ) { TestCaseResult testCase = testCaseStorage . get ( ) ; event . process ( testCase ) ; Step root = stepStorage . pollLast ( ) ; if ( Status . PASSED . equals ( testCase . getStatus ( ) ) ) { new RemoveAttachmentsEvent ( AllureConfig . newInstance ( ) . getRemoveAttachmen...
Process TestCaseFinishedEvent . Add steps and attachments from top step from stepStorage to current testCase then remove testCase and step from stores . Also remove attachments matches removeAttachments config .
146,563
public static String strMapToStr ( Map < String , String > map ) { StringBuilder sb = new StringBuilder ( ) ; if ( map == null || map . isEmpty ( ) ) return sb . toString ( ) ; for ( Entry < String , String > entry : map . entrySet ( ) ) { sb . append ( "< " + entry . getKey ( ) + ", " + entry . getValue ( ) + "> " ) ;...
Str map to str .
146,564
public static String getAggregatedResultHuman ( Map < String , LinkedHashSet < String > > aggregateResultMap ) { StringBuilder res = new StringBuilder ( ) ; for ( Entry < String , LinkedHashSet < String > > entry : aggregateResultMap . entrySet ( ) ) { LinkedHashSet < String > valueSet = entry . getValue ( ) ; res . ap...
Get the aggregated result human readable string for easy display .
146,565
public static String renderJson ( Object o ) { Gson gson = new GsonBuilder ( ) . disableHtmlEscaping ( ) . setPrettyPrinting ( ) . create ( ) ; return gson . toJson ( o ) ; }
Render json .
146,566
public void sendMessageUntilStopCount ( int stopCount ) { for ( int i = processedWorkerCount ; i < workers . size ( ) ; ++ i ) { ActorRef worker = workers . get ( i ) ; try { Thread . sleep ( 1L ) ; } catch ( InterruptedException e ) { logger . error ( "sleep exception " + e + " details: " , e ) ; } worker . tell ( Ope...
Note that if there is sleep in this method .
146,567
public void waitAndRetry ( ) { ContinueToSendToBatchSenderAsstManager continueToSendToBatchSenderAsstManager = new ContinueToSendToBatchSenderAsstManager ( processedWorkerCount ) ; logger . debug ( "NOW WAIT Another " + asstManagerRetryIntervalMillis + " MS. at " + PcDateUtils . getNowDateTimeStrStandard ( ) ) ; getCon...
Wait and retry .
146,568
public String getUuidFromResponse ( ResponseOnSingeRequest myResponse ) { String uuid = PcConstants . NA ; String responseBody = myResponse . getResponseBody ( ) ; Pattern regex = Pattern . compile ( getJobIdRegex ( ) ) ; Matcher matcher = regex . matcher ( responseBody ) ; if ( matcher . matches ( ) ) { uuid = matcher...
Gets the uuid from response .
146,569
public double getProgressFromResponse ( ResponseOnSingeRequest myResponse ) { double progress = 0.0 ; try { if ( myResponse == null || myResponse . isFailObtainResponse ( ) ) { return progress ; } String responseBody = myResponse . getResponseBody ( ) ; Pattern regex = Pattern . compile ( progressRegex ) ; Matcher matc...
Gets the progress from response .
146,570
public boolean ifTaskCompletedSuccessOrFailureFromResponse ( ResponseOnSingeRequest myResponse ) { boolean isCompleted = false ; try { if ( myResponse == null || myResponse . isFailObtainResponse ( ) ) { return isCompleted ; } String responseBody = myResponse . getResponseBody ( ) ; if ( responseBody . matches ( succes...
If task completed success or failure from response .
146,571
public BoundRequestBuilder createRequest ( ) throws HttpRequestCreateException { BoundRequestBuilder builder = null ; getLogger ( ) . debug ( "AHC completeUrl " + requestUrl ) ; try { switch ( httpMethod ) { case GET : builder = client . prepareGet ( requestUrl ) ; break ; case POST : builder = client . preparePost ( r...
Creates the request .
146,572
public ResponseOnSingeRequest onComplete ( Response response ) { cancelCancellable ( ) ; try { Map < String , List < String > > responseHeaders = null ; if ( responseHeaderMeta != null ) { responseHeaders = new LinkedHashMap < String , List < String > > ( ) ; if ( responseHeaderMeta . isGetAll ( ) ) { for ( Map . Entry...
On complete . Save response headers when needed .
146,573
public void onThrowable ( Throwable cause ) { this . cause = cause ; getSelf ( ) . tell ( RequestWorkerMsgType . PROCESS_ON_EXCEPTION , getSelf ( ) ) ; }
On throwable .
146,574
public static List < String > getNodeListFromStringLineSeperateOrSpaceSeperate ( String listStr , boolean removeDuplicate ) { List < String > nodes = new ArrayList < String > ( ) ; for ( String token : listStr . split ( "[\\r?\\n| +]+" ) ) { if ( token != null && ! token . trim ( ) . isEmpty ( ) ) { nodes . add ( token...
Gets the node list from string line seperate or space seperate .
146,575
public static int removeDuplicateNodeList ( List < String > list ) { int originCount = list . size ( ) ; HashSet < String > hs = new LinkedHashSet < String > ( ) ; hs . addAll ( list ) ; list . clear ( ) ; list . addAll ( hs ) ; return originCount - list . size ( ) ; }
Removes the duplicate node list .
146,576
public ParallelTaskBuilder setResponseContext ( Map < String , Object > responseContext ) { if ( responseContext != null ) this . responseContext = responseContext ; else logger . error ( "context cannot be null. skip set." ) ; return this ; }
Sets the response context .
146,577
public ParallelTask execute ( ParallecResponseHandler handler ) { ParallelTask task = new ParallelTask ( ) ; try { targetHostMeta = new TargetHostMeta ( targetHosts ) ; final ParallelTask taskReal = new ParallelTask ( requestProtocol , concurrency , httpMeta , targetHostMeta , sshMeta , tcpMeta , udpMeta , pingMeta , h...
key function . first validate if the ACM has adequate data ; then execute it after the validation . the new ParallelTask task guareetee to have the targethost meta and command meta not null
146,578
public boolean validation ( ) throws ParallelTaskInvalidException { ParallelTask task = new ParallelTask ( ) ; targetHostMeta = new TargetHostMeta ( targetHosts ) ; task = new ParallelTask ( requestProtocol , concurrency , httpMeta , targetHostMeta , sshMeta , tcpMeta , udpMeta , pingMeta , null , responseContext , rep...
add some validation to see if this miss anything .
146,579
public ParallelTaskBuilder setTargetHostsFromJsonPath ( String jsonPath , String sourcePath , HostsSourceType sourceType ) throws TargetHostsLoadException { this . targetHosts = targetHostBuilder . setTargetHostsFromJsonPath ( jsonPath , sourcePath , sourceType ) ; return this ; }
Sets the target hosts from json path .
146,580
public ParallelTaskBuilder setTargetHostsFromLineByLineText ( String sourcePath , HostsSourceType sourceType ) throws TargetHostsLoadException { this . targetHosts = targetHostBuilder . setTargetHostsFromLineByLineText ( sourcePath , sourceType ) ; return this ; }
Sets the target hosts from line by line text .
146,581
public ParallelTaskBuilder setReplacementVarMapNodeSpecific ( Map < String , StrStrMap > replacementVarMapNodeSpecific ) { this . replacementVarMapNodeSpecific . clear ( ) ; this . replacementVarMapNodeSpecific . putAll ( replacementVarMapNodeSpecific ) ; this . requestReplacementType = RequestReplacementType . TARGET_...
Sets the replacement var map node specific .
146,582
public ParallelTaskBuilder setReplaceVarMapToSingleTargetFromMap ( Map < String , StrStrMap > replacementVarMapNodeSpecific , String uniformTargetHost ) { setReplacementVarMapNodeSpecific ( replacementVarMapNodeSpecific ) ; if ( Strings . isNullOrEmpty ( uniformTargetHost ) ) { logger . error ( "uniform target host is ...
Sets the replace var map to single target from map .
146,583
public ParallelTaskBuilder setReplaceVarMapToSingleTargetSingleVar ( String variable , List < String > replaceList , String uniformTargetHost ) { if ( Strings . isNullOrEmpty ( uniformTargetHost ) ) { logger . error ( "uniform target host is empty or null. skil setting." ) ; return this ; } this . replacementVarMapNode...
Sets the replace var map to single target single var .
146,584
public ParallelTaskBuilder setReplaceVarMapToSingleTarget ( List < StrStrMap > replacementVarMapList , String uniformTargetHost ) { if ( Strings . isNullOrEmpty ( uniformTargetHost ) ) { logger . error ( "uniform target host is empty or null. skil setting." ) ; return this ; } this . replacementVarMapNodeSpecific . cle...
Sets the replace var map to single target .
146,585
public ParallelTaskBuilder setReplacementVarMap ( Map < String , String > replacementVarMap ) { this . replacementVarMap = replacementVarMap ; this . requestReplacementType = RequestReplacementType . UNIFORM_VAR_REPLACEMENT ; return this ; }
Sets the replacement var map .
146,586
public ParallelTaskBuilder setHttpPollerProcessor ( HttpPollerProcessor httpPollerProcessor ) { this . httpMeta . setHttpPollerProcessor ( httpPollerProcessor ) ; this . httpMeta . setPollable ( true ) ; return this ; }
Sets the HTTP poller processor to handle Async API . Will auto enable the pollable mode with this call
146,587
public ParallelTaskBuilder setSshPassword ( String password ) { this . sshMeta . setPassword ( password ) ; this . sshMeta . setSshLoginType ( SshLoginType . PASSWORD ) ; return this ; }
Sets the ssh password .
146,588
public ParallelTaskBuilder setSshPrivKeyRelativePath ( String privKeyRelativePath ) { this . sshMeta . setPrivKeyRelativePath ( privKeyRelativePath ) ; this . sshMeta . setSshLoginType ( SshLoginType . KEY ) ; return this ; }
Sets the ssh priv key relative path . Note that must be relative path for now . This default to no need of passphrase for the private key . Will also auto set the login type to key based .
146,589
public ParallelTaskBuilder setSshPrivKeyRelativePathWtihPassphrase ( String privKeyRelativePath , String passphrase ) { this . sshMeta . setPrivKeyRelativePath ( privKeyRelativePath ) ; this . sshMeta . setPrivKeyUsePassphrase ( true ) ; this . sshMeta . setPassphrase ( passphrase ) ; this . sshMeta . setSshLoginType (...
Sets the ssh priv key relative path wtih passphrase .
146,590
public static String getDateTimeStr ( Date d ) { if ( d == null ) return "" ; SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss.SSSZ" ) ; return sdf . format ( d ) ; }
Gets the date time str .
146,591
public static String getDateTimeStrStandard ( Date d ) { if ( d == null ) return "" ; if ( d . getTime ( ) == 0L ) return "Never" ; SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy.MM.dd.HH.mm.ss.SSSZ" ) ; return sdf . format ( d ) ; }
Gets the date time str standard .
146,592
public static String getDateTimeStrConcise ( Date d ) { if ( d == null ) return "" ; SimpleDateFormat sdf = new SimpleDateFormat ( "yyyyMMddHHmmssSSSZ" ) ; return sdf . format ( d ) ; }
Gets the date time str concise .
146,593
public static Date getDateFromConciseStr ( String str ) { Date d = null ; if ( str == null || str . isEmpty ( ) ) return null ; try { SimpleDateFormat sdf = new SimpleDateFormat ( "yyyyMMddHHmmssSSSZ" ) ; d = sdf . parse ( str ) ; } catch ( Exception ex ) { logger . error ( ex + "Exception while converting string to da...
20130512 Converts the sdsm string generated above to Date format .
146,594
private final void handleHttpWorkerResponse ( ResponseOnSingeRequest respOnSingleReq ) throws Exception { String responseContent = respOnSingleReq . getResponseBody ( ) ; response . setResponseContent ( respOnSingleReq . getResponseBody ( ) ) ; if ( request . isPollable ( ) ) { boolean scheduleNextPoll = false ; boolea...
Handle http worker response .
146,595
private final void processMainRequest ( ) { sender = getSender ( ) ; startTimeMillis = System . currentTimeMillis ( ) ; timeoutDuration = Duration . create ( request . getActorMaxOperationTimeoutSec ( ) , TimeUnit . SECONDS ) ; actorMaxOperationTimeoutSec = request . getActorMaxOperationTimeoutSec ( ) ; if ( request . ...
the 1st request from the manager .
146,596
@ SuppressWarnings ( "deprecation" ) private final void operationTimeout ( ) { cancelCancellable ( ) ; if ( asyncWorker != null && ! asyncWorker . isTerminated ( ) ) { asyncWorker . tell ( RequestWorkerMsgType . PROCESS_ON_TIMEOUT , getSelf ( ) ) ; } else { logger . info ( "asyncWorker has been killed or uninitialized ...
will trigger workers to cancel then wait for it to report back .
146,597
private final void replyErrors ( final String errorMessage , final String stackTrace , final String statusCode , final int statusCodeInt ) { reply ( true , errorMessage , stackTrace , statusCode , statusCodeInt , PcConstants . NA , null ) ; }
Reply used in error cases . set the response header as null .
146,598
public static void addHeaders ( BoundRequestBuilder builder , Map < String , String > headerMap ) { for ( Entry < String , String > entry : headerMap . entrySet ( ) ) { String name = entry . getKey ( ) ; String value = entry . getValue ( ) ; builder . addHeader ( name , value ) ; } }
Adds the headers .
146,599
@ SuppressWarnings ( "deprecation" ) public boolean cancelOnTargetHosts ( List < String > targetHosts ) { boolean success = false ; try { switch ( state ) { case IN_PROGRESS : if ( executionManager != null && ! executionManager . isTerminated ( ) ) { executionManager . tell ( new CancelTaskOnHostRequest ( targetHosts )...
Cancel on target hosts .