idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
146,600 | public String generateTaskId ( ) { final String uuid = UUID . randomUUID ( ) . toString ( ) . substring ( 0 , 12 ) ; int size = this . targetHostMeta == null ? 0 : this . targetHostMeta . getHosts ( ) . size ( ) ; return "PT_" + size + "_" + PcDateUtils . getNowDateTimeStrConciseNoZone ( ) + "_" + uuid ; } | Gen job id . |
146,601 | public Double getProgress ( ) { if ( state . equals ( ParallelTaskState . IN_PROGRESS ) ) { if ( requestNum != 0 ) { return 100.0 * ( ( double ) responsedNum / ( double ) requestNumActual ) ; } else { return 0.0 ; } } if ( state . equals ( ParallelTaskState . WAITING ) ) { return 0.0 ; } if ( state . equals ( ParallelT... | Gets the progress . |
146,602 | public Map < String , SetAndCount > getAggregateResultFullSummary ( ) { Map < String , SetAndCount > summaryMap = new ConcurrentHashMap < String , SetAndCount > ( ) ; for ( Entry < String , LinkedHashSet < String > > entry : aggregateResultMap . entrySet ( ) ) { summaryMap . put ( entry . getKey ( ) , new SetAndCount (... | Aggregate results to see the status code distribution with target hosts . |
146,603 | public Map < String , Integer > getAggregateResultCountSummary ( ) { Map < String , Integer > summaryMap = new LinkedHashMap < String , Integer > ( ) ; for ( Entry < String , LinkedHashSet < String > > entry : aggregateResultMap . entrySet ( ) ) { summaryMap . put ( entry . getKey ( ) , entry . getValue ( ) . size ( ) ... | Gets the aggregate result count summary . only list the counts for brief understanding |
146,604 | public PerformUsage getJVMMemoryUsage ( ) { int mb = 1024 * 1024 ; Runtime rt = Runtime . getRuntime ( ) ; PerformUsage usage = new PerformUsage ( ) ; usage . totalMemory = ( double ) rt . totalMemory ( ) / mb ; usage . freeMemory = ( double ) rt . freeMemory ( ) / mb ; usage . usedMemory = ( double ) rt . totalMemory ... | Gets the JVM memory usage . |
146,605 | public ThreadInfo [ ] getThreadDump ( ) { ThreadMXBean threadMxBean = ManagementFactory . getThreadMXBean ( ) ; return threadMxBean . dumpAllThreads ( true , true ) ; } | Gets the thread dump . |
146,606 | public ThreadUsage getThreadUsage ( ) { ThreadMXBean threadMxBean = ManagementFactory . getThreadMXBean ( ) ; ThreadUsage threadUsage = new ThreadUsage ( ) ; long [ ] threadIds = threadMxBean . getAllThreadIds ( ) ; threadUsage . liveThreadCount = threadIds . length ; for ( long tId : threadIds ) { ThreadInfo threadInf... | Gets the thread usage . |
146,607 | public String getHealthMemory ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Logging JVM Stats\n" ) ; MonitorProvider mp = MonitorProvider . getInstance ( ) ; PerformUsage perf = mp . getJVMMemoryUsage ( ) ; sb . append ( perf . toString ( ) ) ; if ( perf . memoryUsagePercent >= THRESHOLD_PERCENT ) { s... | Gets the health memory . |
146,608 | public void shutdown ( ) { for ( Entry < HttpClientType , AsyncHttpClient > entry : map . entrySet ( ) ) { AsyncHttpClient client = entry . getValue ( ) ; if ( client != null ) client . close ( ) ; } } | Shutdown each AHC client in the map . |
146,609 | private String getContentFromPath ( String sourcePath , HostsSourceType sourceType ) throws IOException { String res = "" ; if ( sourceType == HostsSourceType . LOCAL_FILE ) { res = PcFileNetworkIoUtils . readFileContentToString ( sourcePath ) ; } else if ( sourceType == HostsSourceType . URL ) { res = PcFileNetworkIoU... | note that for read from file this will just load all to memory . not fit if need to read a very large file . However for getting the host name . normally it is fine . |
146,610 | public List < String > setTargetHostsFromLineByLineText ( String sourcePath , HostsSourceType sourceType ) throws TargetHostsLoadException { List < String > targetHosts = new ArrayList < String > ( ) ; try { String content = getContentFromPath ( sourcePath , sourceType ) ; targetHosts = setTargetHostsFromString ( conte... | get target hosts from line by line . |
146,611 | public ConnectionlessBootstrap bootStrapUdpClient ( ) throws HttpRequestCreateException { ConnectionlessBootstrap udpClient = null ; try { udpClient = new ConnectionlessBootstrap ( udpMeta . getChannelFactory ( ) ) ; udpClient . setPipeline ( new UdpPipelineFactory ( TcpUdpSshPingResourceStore . getInstance ( ) . getTi... | Creates the udpClient with proper handler . |
146,612 | public void initialize ( ) { if ( isClosed . get ( ) ) { logger . info ( "Initialing Parallel Client Resources: actor system, HttpClientStore, Task Manager ...." ) ; ActorConfig . createAndGetActorSystem ( ) ; httpClientStore . init ( ) ; tcpSshPingResourceStore . init ( ) ; isClosed . set ( false ) ; logger . info ( "... | Initialize . create the httpClientStore tcpClientStore |
146,613 | public void reinitIfClosed ( ) { if ( isClosed . get ( ) ) { logger . info ( "External Resource was released. Now Re-initializing resources ..." ) ; ActorConfig . createAndGetActorSystem ( ) ; httpClientStore . reinit ( ) ; tcpSshPingResourceStore . reinit ( ) ; try { Thread . sleep ( 1000l ) ; } catch ( InterruptedExc... | Auto re - initialize external resourced if resources have been already released . |
146,614 | public ParallelTaskBuilder prepareSsh ( ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . setProtocol ( RequestProtocol . SSH ) ; return cb ; } | Prepare a parallel SSH Task . |
146,615 | public ParallelTaskBuilder preparePing ( ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . setProtocol ( RequestProtocol . PING ) ; return cb ; } | Prepare a parallel PING Task . |
146,616 | public ParallelTaskBuilder prepareTcp ( String command ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . setProtocol ( RequestProtocol . TCP ) ; cb . getTcpMeta ( ) . setCommand ( command ) ; return cb ; } | Prepare a parallel TCP Task . |
146,617 | public ParallelTaskBuilder prepareUdp ( String command ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . setProtocol ( RequestProtocol . UDP ) ; cb . getUdpMeta ( ) . setCommand ( command ) ; return cb ; } | Prepare a parallel UDP Task . |
146,618 | public ParallelTaskBuilder prepareHttpGet ( String url ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . getHttpMeta ( ) . setHttpMethod ( HttpMethod . GET ) ; cb . getHttpMeta ( ) . setRequestUrlPostfix ( url ) ; return cb ; } | Prepare a parallel HTTP GET Task . |
146,619 | public ParallelTaskBuilder prepareHttpPost ( String url ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . getHttpMeta ( ) . setHttpMethod ( HttpMethod . POST ) ; cb . getHttpMeta ( ) . setRequestUrlPostfix ( url ) ; return cb ; } | Prepare a parallel HTTP POST Task . |
146,620 | public ParallelTaskBuilder prepareHttpDelete ( String url ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . getHttpMeta ( ) . setHttpMethod ( HttpMethod . DELETE ) ; cb . getHttpMeta ( ) . setRequestUrlPostfix ( url ) ; return cb ; } | Prepare a parallel HTTP DELETE Task . |
146,621 | public ParallelTaskBuilder prepareHttpPut ( String url ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . getHttpMeta ( ) . setHttpMethod ( HttpMethod . PUT ) ; cb . getHttpMeta ( ) . setRequestUrlPostfix ( url ) ; return cb ; } | Prepare a parallel HTTP PUT Task . |
146,622 | public ParallelTaskBuilder prepareHttpHead ( String url ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . getHttpMeta ( ) . setHttpMethod ( HttpMethod . HEAD ) ; cb . getHttpMeta ( ) . setRequestUrlPostfix ( url ) ; return cb ; } | Prepare a parallel HTTP HEAD Task . |
146,623 | public ParallelTaskBuilder prepareHttpOptions ( String url ) { reinitIfClosed ( ) ; ParallelTaskBuilder cb = new ParallelTaskBuilder ( ) ; cb . getHttpMeta ( ) . setHttpMethod ( HttpMethod . OPTIONS ) ; cb . getHttpMeta ( ) . setRequestUrlPostfix ( url ) ; return cb ; } | Prepare a parallel HTTP OPTION Task . |
146,624 | @ SuppressWarnings ( "deprecation" ) private void cancelRequestAndWorkers ( ) { for ( ActorRef worker : workers . values ( ) ) { if ( worker != null && ! worker . isTerminated ( ) ) { worker . tell ( OperationWorkerMsgType . CANCEL , getSelf ( ) ) ; } } logger . info ( "ExecutionManager sending cancelPendingRequest at ... | Cancel request and workers . |
146,625 | @ SuppressWarnings ( "deprecation" ) private void cancelRequestAndWorkerOnHost ( List < String > targetHosts ) { List < String > validTargetHosts = new ArrayList < String > ( workers . keySet ( ) ) ; validTargetHosts . retainAll ( targetHosts ) ; logger . info ( "targetHosts for cancel: Total: {}" + " Valid in current ... | Cancel request and worker on host . |
146,626 | public Session startSshSessionAndObtainSession ( ) { Session session = null ; try { JSch jsch = new JSch ( ) ; if ( sshMeta . getSshLoginType ( ) == SshLoginType . KEY ) { String workingDir = System . getProperty ( "user.dir" ) ; String privKeyAbsPath = workingDir + "/" + sshMeta . getPrivKeyRelativePath ( ) ; logger .... | Start ssh session and obtain session . |
146,627 | public Channel sessionConnectGenerateChannel ( Session session ) throws JSchException { session . connect ( sshMeta . getSshConnectionTimeoutMillis ( ) ) ; ChannelExec channel = ( ChannelExec ) session . openChannel ( "exec" ) ; channel . setCommand ( sshMeta . getCommandLine ( ) ) ; if ( sshMeta . isRunAsSuperUser ( )... | Session connect generate channel . |
146,628 | public ResponseOnSingeRequest genErrorResponse ( Exception t ) { ResponseOnSingeRequest sshResponse = new ResponseOnSingeRequest ( ) ; String displayError = PcErrorMsgUtils . replaceErrorMsg ( t . toString ( ) ) ; sshResponse . setStackTrace ( PcStringUtils . printStackTrace ( t ) ) ; sshResponse . setErrorMessage ( di... | Gen error response . |
146,629 | public void genNodeDataMap ( ParallelTask task ) { TargetHostMeta targetHostMeta = task . getTargetHostMeta ( ) ; HttpMeta httpMeta = task . getHttpMeta ( ) ; String entityBody = httpMeta . getEntityBody ( ) ; String requestContent = HttpMeta . replaceDefaultFullRequestContent ( entityBody ) ; Map < String , NodeReqRes... | Generate node data map . |
146,630 | public void filterUnsafeOrUnnecessaryRequest ( Map < String , NodeReqResponse > nodeDataMapValidSource , Map < String , NodeReqResponse > nodeDataMapValidSafe ) { for ( Entry < String , NodeReqResponse > entry : nodeDataMapValidSource . entrySet ( ) ) { String hostName = entry . getKey ( ) ; NodeReqResponse nrr = entry... | Filter unsafe or unnecessary request . |
146,631 | public ClientBootstrap bootStrapTcpClient ( ) throws HttpRequestCreateException { ClientBootstrap tcpClient = null ; try { tcpClient = new ClientBootstrap ( tcpMeta . getChannelFactory ( ) ) ; tcpClient . setPipelineFactory ( new MyPipelineFactory ( TcpUdpSshPingResourceStore . getInstance ( ) . getTimer ( ) , this , t... | Creates the tcpClient with proper handler . |
146,632 | private void reply ( final String response , final boolean error , final String errorMessage , final String stackTrace , final String statusCode , final int statusCodeInt ) { if ( ! sentReply ) { sentReply = true ; if ( channel != null && channel . isOpen ( ) ) channel . close ( ) . awaitUninterruptibly ( ) ; final Res... | First close the connection . Then reply . |
146,633 | public static String stringMatcherByPattern ( String input , String patternStr ) { String output = PcConstants . SYSTEM_FAIL_MATCH_REGEX ; if ( patternStr == null ) { logger . error ( "patternStr is NULL! (Expected when the aggregation rule is not defined at " + PcDateUtils . getNowDateTimeStrStandard ( ) ) ; return ou... | this remove the linebreak . |
146,634 | public synchronized void initTaskSchedulerIfNot ( ) { if ( scheduler == null ) { scheduler = Executors . newSingleThreadScheduledExecutor ( DaemonThreadFactory . getInstance ( ) ) ; CapacityAwareTaskScheduler runner = new CapacityAwareTaskScheduler ( ) ; scheduler . scheduleAtFixedRate ( runner , ParallecGlobalConfig .... | as it is daemon thread |
146,635 | public synchronized void shutdownTaskScheduler ( ) { if ( scheduler != null && ! scheduler . isShutdown ( ) ) { scheduler . shutdown ( ) ; logger . info ( "shutdowned the task scheduler. No longer accepting new tasks" ) ; scheduler = null ; } } | Shutdown task scheduler . |
146,636 | public ParallelTask getTaskFromInProgressMap ( String jobId ) { if ( ! inprogressTaskMap . containsKey ( jobId ) ) return null ; return inprogressTaskMap . get ( jobId ) ; } | Gets the task from in progress map . |
146,637 | public int getTotalUsedCapacity ( ) { int totalCapacity = 0 ; for ( Entry < String , ParallelTask > entry : inprogressTaskMap . entrySet ( ) ) { ParallelTask task = entry . getValue ( ) ; if ( task != null ) totalCapacity += task . capacityUsed ( ) ; } return totalCapacity ; } | get current total used capacity . |
146,638 | public synchronized void cleanWaitTaskQueue ( ) { for ( ParallelTask task : waitQ ) { task . setState ( ParallelTaskState . COMPLETED_WITH_ERROR ) ; task . getTaskErrorMetas ( ) . add ( new TaskErrorMeta ( TaskErrorType . USER_CANCELED , "NA" ) ) ; logger . info ( "task {} removed from wait q. This task has been marked... | Clean wait task queue . |
146,639 | public synchronized boolean removeTaskFromWaitQ ( ParallelTask taskTobeRemoved ) { boolean removed = false ; for ( ParallelTask task : waitQ ) { if ( task . getTaskId ( ) == taskTobeRemoved . getTaskId ( ) ) { task . setState ( ParallelTaskState . COMPLETED_WITH_ERROR ) ; task . getTaskErrorMetas ( ) . add ( new TaskEr... | Removes the task from wait q . |
146,640 | public ResponseFromManager generateUpdateExecuteTask ( ParallelTask task ) { ParallelTaskManager . getInstance ( ) . addTaskToInProgressMap ( task . getTaskId ( ) , task ) ; logger . info ( "Added task {} to the running inprogress map..." , task . getTaskId ( ) ) ; boolean useReplacementVarMap = false ; boolean useRepl... | key function to execute a parallel task . |
146,641 | @ SuppressWarnings ( "deprecation" ) public ResponseFromManager sendTaskToExecutionManager ( ParallelTask task ) { ResponseFromManager commandResponseFromManager = null ; ActorRef executionManager = null ; try { logger . info ( "!!STARTED sendAgentCommandToManager : " + task . getTaskId ( ) + " at " + PcDateUtils . get... | Send parallel task to execution manager . |
146,642 | public static boolean isFileExist ( String filePath ) { File f = new File ( filePath ) ; return f . exists ( ) && ! f . isDirectory ( ) ; } | Checks if is file exist . |
146,643 | public static String readFileContentToString ( String filePath ) throws IOException { String content = "" ; content = Files . toString ( new File ( filePath ) , Charsets . UTF_8 ) ; return content ; } | Read file content to string . |
146,644 | public static String readStringFromUrlGeneric ( String url ) throws IOException { InputStream is = null ; URL urlObj = null ; String responseString = PcConstants . NA ; try { urlObj = new URL ( url ) ; URLConnection con = urlObj . openConnection ( ) ; con . setConnectTimeout ( ParallecGlobalConfig . urlConnectionConnec... | Read string from url generic . |
146,645 | public void updateRequestByAddingReplaceVarPair ( ParallelTask task , String replaceVarKey , String replaceVarValue ) { Map < String , NodeReqResponse > taskResult = task . getParallelTaskResult ( ) ; for ( Entry < String , NodeReqResponse > entry : taskResult . entrySet ( ) ) { NodeReqResponse nodeReqResponse = entry ... | GENERIC!!! HELPER FUNCION FOR REPLACEMENT |
146,646 | public static ActorSystem createAndGetActorSystem ( ) { if ( actorSystem == null || actorSystem . isTerminated ( ) ) { actorSystem = ActorSystem . create ( PcConstants . ACTOR_SYSTEM , conf ) ; } return actorSystem ; } | Create and get actor system . |
146,647 | public static void shutDownActorSystemForce ( ) { if ( ! actorSystem . isTerminated ( ) ) { logger . info ( "shutting down actor system..." ) ; actorSystem . shutdown ( ) ; actorSystem . awaitTermination ( timeOutDuration ) ; logger . info ( "Actor system has been shut down." ) ; } else { logger . info ( "Actor system ... | Shut down actor system force . |
146,648 | public synchronized void init ( ) { channelFactory = new NioClientSocketChannelFactory ( Executors . newCachedThreadPool ( ) , Executors . newCachedThreadPool ( ) ) ; datagramChannelFactory = new NioDatagramChannelFactory ( Executors . newCachedThreadPool ( ) ) ; timer = new HashedWheelTimer ( ) ; } | Initialize ; cached threadpool is safe as it is releasing resources automatically if idle |
146,649 | public static String replaceErrorMsg ( String origMsg ) { String replaceMsg = origMsg ; for ( ERROR_TYPE errorType : ERROR_TYPE . values ( ) ) { if ( origMsg == null ) { replaceMsg = PcConstants . NA ; return replaceMsg ; } if ( origMsg . contains ( errorMapOrig . get ( errorType ) ) ) { replaceMsg = errorMapReplace . ... | Replace error msg . |
146,650 | private void disableCertificateVerification ( ) throws KeyManagementException , NoSuchAlgorithmException { final TrustManager [ ] trustAllCerts = new TrustManager [ ] { new CustomTrustManager ( ) } ; final SSLContext sslContext = SSLContext . getInstance ( "SSL" ) ; sslContext . init ( null , trustAllCerts , new Secure... | Disable certificate verification . |
146,651 | public static String replaceFullRequestContent ( String requestContentTemplate , String replacementString ) { return ( requestContentTemplate . replace ( PcConstants . COMMAND_VAR_DEFAULT_REQUEST_CONTENT , replacementString ) ) ; } | Replace full request content . |
146,652 | public void addFile ( String description , FileModel fileModel ) { Map < FileModel , ProblemFileSummary > files = addDescription ( description ) ; if ( files . containsKey ( fileModel ) ) { files . get ( fileModel ) . addOccurrence ( ) ; } else { files . put ( fileModel , new ProblemFileSummary ( fileModel , 1 ) ) ; } ... | Adds a file with the provided description . |
146,653 | private boolean shouldIgnore ( String typeReference ) { typeReference = typeReference . replace ( '/' , '.' ) . replace ( '\\' , '.' ) ; return JavaClassIgnoreResolver . singletonInstance ( ) . matches ( typeReference ) ; } | This method is called on every reference that is in the . class file . |
146,654 | public FileModel resolvePayload ( GraphRewrite event , EvaluationContext context , WindupVertexFrame payload ) { checkVariableName ( event , context ) ; if ( payload instanceof FileReferenceModel ) { return ( ( FileReferenceModel ) payload ) . getFile ( ) ; } if ( payload instanceof FileModel ) { return ( FileModel ) p... | Set the payload to the fileModel of the given instance even though the variable is not directly referencing it . This is mainly to simplify the creation of the rule when the FileModel itself is not being iterated but just a model referencing it . |
146,655 | public static FreeMarkerOperation create ( Furnace furnace , String templatePath , String outputFilename , String ... varNames ) { return new FreeMarkerOperation ( furnace , templatePath , outputFilename , varNames ) ; } | Create a FreeMarkerOperation with the provided furnace instance template path and varNames . |
146,656 | private void recurseAndAddFiles ( GraphRewrite event , EvaluationContext context , Path tempFolder , FileService fileService , ArchiveModel archiveModel , FileModel parentFileModel , boolean subArchivesOnly ) { checkCancelled ( event ) ; int numberAdded = 0 ; FileFilter filter = TrueFileFilter . TRUE ; if ( archiveMode... | Recurses the given folder and adds references to these files to the graph as FileModels . |
146,657 | private void renderAsLI ( Writer writer , ProjectModel project , Iterator < Link > links , boolean wrap ) throws IOException { if ( ! links . hasNext ( ) ) return ; if ( wrap ) writer . append ( "<ul>" ) ; while ( links . hasNext ( ) ) { Link link = links . next ( ) ; writer . append ( "<li>" ) ; renderLink ( writer , ... | Renders in LI tags Wraps with UL tags optionally . |
146,658 | private ApplicationReportIndexModel createApplicationReportIndex ( GraphContext context , ProjectModel applicationProjectModel ) { ApplicationReportIndexService applicationReportIndexService = new ApplicationReportIndexService ( context ) ; ApplicationReportIndexModel index = applicationReportIndexService . create ( ) ... | Create the index and associate it with all project models in the Application |
146,659 | private void addAllProjectModels ( ApplicationReportIndexModel navIdx , ProjectModel projectModel ) { navIdx . addProjectModel ( projectModel ) ; for ( ProjectModel childProject : projectModel . getChildProjects ( ) ) { if ( ! Iterators . asSet ( navIdx . getProjectModels ( ) ) . contains ( childProject ) ) addAllProje... | Attach all project models within the application to the index . This will make it easy to navigate from the projectModel to the application index . |
146,660 | public long getTimeRemainingInMillis ( ) { long batchTime = System . currentTimeMillis ( ) - startTime ; double timePerIteration = ( double ) batchTime / ( double ) worked . get ( ) ; return ( long ) ( timePerIteration * ( total - worked . get ( ) ) ) ; } | Gets the estimated time remaining in milliseconds based upon the total number of work units the start time and how many units have been done so far . |
146,661 | public FileModel getChildFile ( ArchiveModel archiveModel , String filePath ) { filePath = FilenameUtils . separatorsToUnix ( filePath ) ; StringTokenizer stk = new StringTokenizer ( filePath , "/" ) ; FileModel currentFileModel = archiveModel ; while ( stk . hasMoreTokens ( ) && currentFileModel != null ) { String pat... | Finds the file at the provided path within the archive . |
146,662 | private void sort ( ) { DefaultDirectedWeightedGraph < RuleProvider , DefaultEdge > graph = new DefaultDirectedWeightedGraph < > ( DefaultEdge . class ) ; for ( RuleProvider provider : providers ) { graph . addVertex ( provider ) ; } addProviderRelationships ( graph ) ; checkForCycles ( graph ) ; List < RuleProvider > ... | Perform the entire sort operation |
146,663 | private void checkForCycles ( DefaultDirectedWeightedGraph < RuleProvider , DefaultEdge > graph ) { CycleDetector < RuleProvider , DefaultEdge > cycleDetector = new CycleDetector < > ( graph ) ; if ( cycleDetector . detectCycles ( ) ) { Set < RuleProvider > cycles = cycleDetector . findCycles ( ) ; StringBuilder errorS... | Use the jgrapht cycle checker to detect any cycles in the provided dependency graph . |
146,664 | private void recurseAndAddFiles ( GraphRewrite event , FileService fileService , WindupJavaConfigurationService javaConfigurationService , FileModel file ) { if ( javaConfigurationService . checkIfIgnored ( event , file ) ) return ; String filePath = file . getFilePath ( ) ; File fileReference = new File ( filePath ) ;... | Recurses the given folder and creates the FileModels vertices for the child files to the graph . |
146,665 | public static void checkFileOrDirectoryToBeRead ( File fileOrDir , String fileDesc ) { if ( fileOrDir == null ) throw new IllegalArgumentException ( fileDesc + " must not be null." ) ; if ( ! fileOrDir . exists ( ) ) throw new IllegalArgumentException ( fileDesc + " does not exist: " + fileOrDir . getAbsolutePath ( ) )... | Throws if the given file is null is not a file or directory or is an empty directory . |
146,666 | public List < URL > scan ( Predicate < String > filter ) { List < URL > discoveredURLs = new ArrayList < > ( 128 ) ; for ( Addon addon : furnace . getAddonRegistry ( ) . getAddons ( AddonFilters . allStarted ( ) ) ) { List < String > filteredResourcePaths = filterAddonResources ( addon , filter ) ; for ( String filePat... | Scans all Forge addons for files accepted by given filter . |
146,667 | public List < Class < ? > > scanClasses ( Predicate < String > filter ) { List < Class < ? > > discoveredClasses = new ArrayList < > ( 128 ) ; for ( Addon addon : furnace . getAddonRegistry ( ) . getAddons ( AddonFilters . allStarted ( ) ) ) { List < String > discoveredFileNames = filterAddonResources ( addon , filter ... | Scans all Forge addons for classes accepted by given filter . |
146,668 | public List < String > filterAddonResources ( Addon addon , Predicate < String > filter ) { List < String > discoveredFileNames = new ArrayList < > ( ) ; List < File > addonResources = addon . getRepository ( ) . getAddonResources ( addon . getId ( ) ) ; for ( File addonFile : addonResources ) { if ( addonFile . isDire... | Returns a list of files in given addon passing given filter . |
146,669 | private void handleArchiveByFile ( Predicate < String > filter , File archive , List < String > discoveredFiles ) { try { try ( ZipFile zip = new ZipFile ( archive ) ) { Enumeration < ? extends ZipEntry > entries = zip . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry entry = entries . nextElement ( ) ... | Scans given archive for files passing given filter adds the results into given list . |
146,670 | private void handleDirectory ( final Predicate < String > filter , final File rootDir , final List < String > discoveredFiles ) { try { new DirectoryWalker < String > ( ) { private Path startDir ; public void walk ( ) throws IOException { this . startDir = rootDir . toPath ( ) ; this . walk ( rootDir , discoveredFiles ... | Scans given directory for files passing given filter adds the results into given list . |
146,671 | public static Project dependsOnArtifact ( Artifact artifact ) { Project project = new Project ( ) ; project . artifact = artifact ; return project ; } | Specify the Artifact for which the condition should search for . |
146,672 | public static final < T > T getSingle ( Iterable < T > it ) { if ( ! it . iterator ( ) . hasNext ( ) ) return null ; final Iterator < T > iterator = it . iterator ( ) ; T o = iterator . next ( ) ; if ( iterator . hasNext ( ) ) throw new IllegalStateException ( "Found multiple items in iterator over " + o . getClass ( )... | Returns a single item from the Iterator . If there s none returns null . If there are more throws an IllegalStateException . |
146,673 | public void perform ( GraphRewrite event , EvaluationContext context ) { checkVariableName ( event , context ) ; WindupVertexFrame payload = resolveVariable ( event , getVariableName ( ) ) ; if ( payload instanceof FileReferenceModel ) { FileModel file = ( ( FileReferenceModel ) payload ) . getFile ( ) ; perform ( even... | Set the payload to the fileModel of the given instance even though the variable is not directly of it s type . This is mainly to simplify the creation of the rule when the FileModel itself is not being iterated but just a model referencing it . |
146,674 | public Project dependsOnArtifact ( Artifact artifact ) { Project project = new Project ( ) ; project . setArtifact ( artifact ) ; project . setInputVariablesName ( inputVarName ) ; return project ; } | Specify the artifact configuration to be searched for |
146,675 | public static JmsDestinationType getTypeFromClass ( String aClass ) { if ( StringUtils . equals ( aClass , "javax.jms.Queue" ) || StringUtils . equals ( aClass , "javax.jms.QueueConnectionFactory" ) ) { return JmsDestinationType . QUEUE ; } else if ( StringUtils . equals ( aClass , "javax.jms.Topic" ) || StringUtils . ... | Gets JmsDestinationType from java class name |
146,676 | protected void checkVariableName ( GraphRewrite event , EvaluationContext context ) { if ( variableName == null ) { setVariableName ( Iteration . getPayloadVariableName ( event , context ) ) ; } } | Check the variable name and if not set set it with the singleton variable name being on the top of the stack . |
146,677 | public static List < ClassReference > analyze ( WildcardImportResolver importResolver , Set < String > libraryPaths , Set < String > sourcePaths , Path sourceFile ) { ASTParser parser = ASTParser . newParser ( AST . JLS11 ) ; parser . setEnvironment ( libraryPaths . toArray ( new String [ libraryPaths . size ( ) ] ) , ... | Parses the provided file using the given libraryPaths and sourcePaths as context . The libraries may be either jar files or references to directories containing class files . |
146,678 | public static final String vertexAsString ( Vertex vertex , int depth , String withEdgesOfLabel ) { StringBuilder sb = new StringBuilder ( ) ; vertexAsString ( vertex , depth , withEdgesOfLabel , sb , 0 , new HashSet < > ( ) ) ; return sb . toString ( ) ; } | Formats a vertex using it s properties . Debugging purposes . |
146,679 | private static String normalizeDirName ( String name ) { if ( name == null ) return null ; return name . toLowerCase ( ) . replaceAll ( "[^a-zA-Z0-9]" , "-" ) ; } | Normalizes the name so it can be used as Maven artifactId or groupId . |
146,680 | private static String guessPackaging ( ProjectModel projectModel ) { String projectType = projectModel . getProjectType ( ) ; if ( projectType != null ) return projectType ; LOG . warning ( "WINDUP-983 getProjectType() returned null for: " + projectModel . getRootFileModel ( ) . getPrettyPath ( ) ) ; String suffix = St... | Tries to guess the packaging of the archive - whether it s an EAR WAR JAR . Maybe not needed as we can rely on the suffix? |
146,681 | public static boolean xpathExists ( Node document , String xpathExpression , Map < String , String > namespaceMapping ) throws XPathException , MarshallingException { Boolean result = ( Boolean ) executeXPath ( document , xpathExpression , namespaceMapping , XPathConstants . BOOLEAN ) ; return result != null && result ... | Runs the given xpath and returns a boolean result . |
146,682 | public static Object executeXPath ( Node document , String xpathExpression , Map < String , String > namespaceMapping , QName result ) throws XPathException , MarshallingException { NamespaceMapContext mapContext = new NamespaceMapContext ( namespaceMapping ) ; try { XPathFactory xPathfactory = XPathFactory . newInstan... | Executes the given xpath and returns the result with the type specified . |
146,683 | String deriveGroupIdFromPackages ( ProjectModel projectModel ) { Map < Object , Long > pkgsMap = new HashMap < > ( ) ; Set < String > pkgs = new HashSet < > ( 1000 ) ; GraphTraversal < Vertex , Vertex > pipeline = new GraphTraversalSource ( graphContext . getGraph ( ) ) . V ( projectModel ) ; pkgsMap = pipeline . out (... | Counts the packages prefixes appearing in this project and if some of them make more than half of the total of existing packages this prefix is returned . Otherwise returns null . |
146,684 | public JavaClassBuilderAt at ( TypeReferenceLocation ... locations ) { if ( locations != null ) this . locations = Arrays . asList ( locations ) ; return this ; } | Only match if the TypeReference is at the specified location within the file . |
146,685 | public ConditionBuilder as ( String variable ) { Assert . notNull ( variable , "Variable name must not be null." ) ; this . setOutputVariablesName ( variable ) ; return this ; } | Optionally specify the variable name to use for the output of this condition |
146,686 | protected void setResults ( GraphRewrite event , String variable , Iterable < ? extends WindupVertexFrame > results ) { Variables variables = Variables . instance ( event ) ; Iterable < ? extends WindupVertexFrame > existingVariables = variables . findVariable ( variable , 1 ) ; if ( existingVariables != null ) { varia... | This sets the variable with the given name to the given value . If there is already a variable with the same name in the top - most stack frame we will combine them here . |
146,687 | private Map < String , Class < ? extends RulePhase > > loadPhases ( ) { Map < String , Class < ? extends RulePhase > > phases ; phases = new HashMap < > ( ) ; Furnace furnace = FurnaceHolder . getFurnace ( ) ; for ( RulePhase phase : furnace . getAddonRegistry ( ) . getServices ( RulePhase . class ) ) { @ SuppressWarni... | Loads the currently known phases from Furnace to the map . |
146,688 | private void allInput ( List < FileModel > vertices , GraphRewrite event , ParameterStore store ) { if ( StringUtils . isBlank ( getInputVariablesName ( ) ) && this . filenamePattern == null ) { FileService fileModelService = new FileService ( event . getGraphContext ( ) ) ; for ( FileModel fileModel : fileModelService... | Generating the input vertices is quite complex . Therefore there are multiple methods that handles the input vertices based on the attribute specified in specific order . This method generates all the vertices if there is no other way how to handle the input . |
146,689 | public T getById ( Object id ) { return context . getFramed ( ) . getFramedVertex ( this . type , id ) ; } | Returns the vertex with given ID framed into given interface . |
146,690 | public static < T extends WindupVertexFrame > T addTypeToModel ( GraphContext graphContext , WindupVertexFrame frame , Class < T > type ) { Vertex vertex = frame . getElement ( ) ; graphContext . getGraphTypeManager ( ) . addTypeToElement ( type , vertex ) ; return graphContext . getFramed ( ) . frameElement ( vertex ,... | Adds the specified type to this frame and returns a new object that implements this type . |
146,691 | public static < T extends WindupVertexFrame > WindupVertexFrame removeTypeFromModel ( GraphContext graphContext , WindupVertexFrame frame , Class < T > type ) { Vertex vertex = frame . getElement ( ) ; graphContext . getGraphTypeManager ( ) . removeTypeFromElement ( type , vertex ) ; return graphContext . getFramed ( )... | Removes the specified type from the frame . |
146,692 | @ SuppressWarnings ( "unchecked" ) private static synchronized Map < String , Boolean > getCache ( GraphRewrite event ) { Map < String , Boolean > result = ( Map < String , Boolean > ) event . getRewriteContext ( ) . get ( ClassificationServiceCache . class ) ; if ( result == null ) { result = Collections . synchronize... | Keep a cache of items files associated with classification in order to improve performance . |
146,693 | public static String getEffortLevelDescription ( Verbosity verbosity , int points ) { EffortLevel level = EffortLevel . forPoints ( points ) ; switch ( verbosity ) { case ID : return level . name ( ) ; case VERBOSE : return level . getVerboseDescription ( ) ; case SHORT : default : return level . getShortDescription ( ... | Returns the right string representation of the effort level based on given number of points . |
146,694 | public WindupConfiguration setOptionValue ( String name , Object value ) { configurationOptions . put ( name , value ) ; return this ; } | Sets a configuration option to the specified value . |
146,695 | @ SuppressWarnings ( "unchecked" ) public < T > T getOptionValue ( String name ) { return ( T ) configurationOptions . get ( name ) ; } | Returns the configuration value with the specified name . |
146,696 | private void logTimeTakenByRuleProvider ( GraphContext graphContext , Context context , int ruleIndex , int timeTaken ) { AbstractRuleProvider ruleProvider = ( AbstractRuleProvider ) context . get ( RuleMetadataType . RULE_PROVIDER ) ; if ( ruleProvider == null ) return ; if ( ! timeTakenByProvider . containsKey ( rule... | Logs the time taken by this rule and attaches this to the total for the RuleProvider |
146,697 | private void logTimeTakenByPhase ( GraphContext graphContext , Class < ? extends RulePhase > phase , int timeTaken ) { if ( ! timeTakenByPhase . containsKey ( phase ) ) { RulePhaseExecutionStatisticsModel model = new GraphService < > ( graphContext , RulePhaseExecutionStatisticsModel . class ) . create ( ) ; model . se... | Logs the time taken by this rule and adds this to the total time taken for this phase |
146,698 | public static String transformXPath ( String originalXPath ) { List < StringBuilder > compiledXPaths = new ArrayList < > ( 1 ) ; int frameIdx = - 1 ; boolean inQuote = false ; int conditionLevel = 0 ; char startQuoteChar = 0 ; StringBuilder currentXPath = new StringBuilder ( ) ; compiledXPaths . add ( currentXPath ) ; ... | Performs the conversion from standard XPath to xpath with parameterization support . |
146,699 | public void accept ( IBinaryType binaryType , PackageBinding packageBinding , AccessRestriction accessRestriction ) { if ( this . options . verbose ) { this . out . println ( Messages . bind ( Messages . compilation_loadBinary , new String ( binaryType . getName ( ) ) ) ) ; } LookupEnvironment env = packageBinding . en... | Add an additional binary type |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.