idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
132,800
static String acquireLock ( ZooKeeper zookeeper , String lockNode ) throws KeeperException , InterruptedException { String placeInLine = takeQueueTicket ( zookeeper , lockNode ) ; logger . debug ( "Acquiring lock, waiting in queue: {}." , placeInLine ) ; return waitInLine ( zookeeper , lockNode , placeInLine ) ; }
Try to acquire a lock on for choosing a resource . This method will wait until it has acquired the lock .
132,801
static String takeQueueTicket ( ZooKeeper zookeeper , String lockNode ) throws InterruptedException , KeeperException { String ticket = String . format ( "nr-%014d-%04d" , System . currentTimeMillis ( ) , random . nextInt ( 10000 ) ) ; if ( grabTicket ( zookeeper , lockNode , ticket ) ) { return ticket ; } else { retur...
Take a ticket for the queue . If the ticket was already claimed by another process this method retries until it succeeds .
132,802
static void releaseTicket ( ZooKeeper zookeeper , String lockNode , String ticket ) throws KeeperException , InterruptedException { logger . debug ( "Releasing ticket {}." , ticket ) ; try { zookeeper . delete ( lockNode + "/" + ticket , - 1 ) ; } catch ( KeeperException e ) { if ( e . code ( ) != KeeperException . Cod...
Release an acquired lock .
132,803
static String waitInLine ( ZooKeeper zookeeper , String lockNode , String placeInLine ) throws KeeperException , InterruptedException { List < String > children = zookeeper . getChildren ( lockNode , false ) ; Collections . sort ( children ) ; if ( children . size ( ) == 0 ) { logger . warn ( "getChildren() returned em...
Wait in the queue until the znode in front of us changes .
132,804
static boolean grabTicket ( ZooKeeper zookeeper , String lockNode , String ticket ) throws InterruptedException , KeeperException { try { zookeeper . create ( lockNode + "/" + ticket , new byte [ 0 ] , ZooDefs . Ids . OPEN_ACL_UNSAFE , CreateMode . EPHEMERAL ) ; } catch ( KeeperException e ) { if ( e . code ( ) == Keep...
Grab a ticket in the queue .
132,805
int claimResource ( ZooKeeper zookeeper , String poolNode , int poolSize ) throws KeeperException , InterruptedException { logger . debug ( "Trying to claim a resource." ) ; List < String > claimedResources = zookeeper . getChildren ( poolNode , false ) ; if ( claimedResources . size ( ) >= poolSize ) { logger . debug ...
Try to claim an available resource from the resource pool .
132,806
private void relinquishResource ( ZooKeeper zookeeper , String poolNode , int resource ) { logger . debug ( "Relinquishing claimed resource {}." , resource ) ; try { zookeeper . delete ( poolNode + "/" + Integer . toString ( resource ) , - 1 ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrup...
Relinquish a claimed resource .
132,807
public static int get ( ZooKeeper zookeeper , String znode ) throws IOException { try { Stat stat = zookeeper . exists ( znode + CLUSTER_ID_NODE , false ) ; if ( stat == null ) { mkdirp ( zookeeper , znode ) ; create ( zookeeper , znode + CLUSTER_ID_NODE , String . valueOf ( DEFAULT_CLUSTER_ID ) . getBytes ( ) ) ; } by...
Retrieves the numeric cluster ID from the ZooKeeper quorum .
132,808
static List < String > pathParts ( String path ) { String [ ] pathParts = path . split ( "/" ) ; List < String > parts = new ArrayList < > ( pathParts . length ) ; String pathSoFar = "" ; for ( String pathPart : pathParts ) { if ( ! pathPart . equals ( "" ) ) { pathSoFar += "/" + pathPart ; parts . add ( pathSoFar ) ; ...
Parse a znode path and return a list containing the full paths to its constituent directories .
132,809
public synchronized static IDGenerator generatorFor ( int generatorId , int clusterId , Mode mode ) { assertParameterWithinBounds ( "generatorId" , 0 , Blueprint . MAX_GENERATOR_ID , generatorId ) ; assertParameterWithinBounds ( "clusterId" , 0 , Blueprint . MAX_CLUSTER_ID , clusterId ) ; String generatorAndCluster = S...
Return the UniqueIDGenerator instance for this specific generator - ID cluster - ID combination . If one was already created that is returned .
132,810
private ZooKeeper connect ( String quorumAddresses ) throws IOException { final CountDownLatch latch = new CountDownLatch ( 1 ) ; ZooKeeper zookeeper ; zookeeper = new ZooKeeper ( quorumAddresses , ( int ) SECONDS . toMillis ( 10 ) , watchedEvent -> { if ( watchedEvent . getState ( ) == Watcher . Event . KeeperState . ...
Connect to the ZooKeeper quorum or timeout if it is unreachable .
132,811
byte [ ] popOne ( ) throws GeneratorException { try { return idStack . pop ( ) ; } catch ( NoSuchElementException e ) { idStack . addAll ( generator . batch ( batchSize ) ) ; return popOne ( ) ; } }
Grab a single ID from the stack . If the stack is empty load up a new batch from the wrapped generator .
132,812
public static byte [ ] build ( Blueprint blueprint ) { ByteBuffer bb = ByteBuffer . allocate ( 8 ) ; switch ( blueprint . getMode ( ) ) { case SPREAD : long reverseTimestamp = Long . reverse ( blueprint . getTimestamp ( ) ) ; bb . putLong ( reverseTimestamp ) ; break ; case TIME_SEQUENTIAL : long timestamp = blueprint ...
Perform all the byte mangling needed to create the eight byte ID .
132,813
private void ensureAccessible ( Key < ? > key , GinjectorBindings parent , GinjectorBindings child ) { if ( parent != null && ! child . equals ( parent ) && ! child . isBound ( key ) ) { PrettyPrinter . log ( logger , TreeLogger . DEBUG , "In %s: inheriting binding for %s from the parent %s" , child , key , parent ) ; ...
Ensure that the binding for key which exists in the parent Ginjector is also available to the child Ginjector .
132,814
public Key < ? > getKey ( FieldLiteral < ? > field ) { return getKey ( field . getFieldType ( ) . getType ( ) , field . getBindingAnnotation ( ) ) ; }
Returns a key based on the passed field taking any binding annotations into account .
132,815
private Key < ? > getKey ( Type type , Annotation bindingAnnotation ) throws ProvisionException { if ( bindingAnnotation == null ) { return Key . get ( type ) ; } else { return Key . get ( type , bindingAnnotation ) ; } }
Gets the Guice binding key for a given Java type with optional annotations .
132,816
public Collection < Dependency > getMemberInjectionDependencies ( Key < ? > typeKey , TypeLiteral < ? > type ) { Set < Dependency > required = new LinkedHashSet < Dependency > ( ) ; for ( MethodLiteral < ? , Method > method : memberCollector . getMethods ( type ) ) { required . addAll ( getDependencies ( typeKey , meth...
Collects and returns all keys required to member - inject the given class .
132,817
public Collection < Dependency > getDependencies ( Key < ? > typeKey , MethodLiteral < ? , ? > method ) { String context ; if ( method . isConstructor ( ) ) { context = "@Inject constructor of " + method . getDeclaringType ( ) ; } else if ( typeKey == Dependency . GINJECTOR ) { context = "Member injector " + method ; }...
Collects and returns all keys required to inject the given method .
132,818
public static < T > FieldLiteral < T > get ( Field field , TypeLiteral < T > declaringType ) { Preconditions . checkArgument ( field . getDeclaringClass ( ) . equals ( declaringType . getRawType ( ) ) , "declaringType (%s) must be the type literal where field was declared (%s)!" , declaringType , field . getDeclaringCl...
Returns a new field literal based on the passed field and its declaring type .
132,819
public PlayerGuessResult displayNextCard ( RelationshipToPreviousCard guess ) { Card card = deck . turnCard ( ) ; grid . nextCard ( card ) ; cardsTurnedPlusOne ++ ; RelationshipToPreviousCard actualRelationshipToPrevious = getRelationshipToPreviousCard ( card ) ; previous = card ; if ( actualRelationshipToPrevious == n...
Turn the next card .
132,820
protected final < T > GinAnnotatedBindingBuilder < T > bind ( Class < T > clazz ) { return binder . bind ( clazz ) ; }
Everything below is copied from AbstractGinModule
132,821
public static boolean isConstantKey ( Key < ? > key ) { Type type = key . getTypeLiteral ( ) . getType ( ) ; if ( ! ( type instanceof Class ) ) { return false ; } Class clazz = ( Class ) type ; return clazz == String . class || clazz == Class . class || clazz . isPrimitive ( ) || Number . class . isAssignableFrom ( cla...
Returns true if the provided key is a valid constant key i . e . if a constant binding can be legally created for it .
132,822
public static void log ( TreeLogger logger , TreeLogger . Type type , String formatString , Object ... args ) { if ( logger . isLoggable ( type ) ) { logger . log ( type , format ( formatString , args ) ) ; } }
Log a pretty - printed message if the given log level is active . The message is only formatted if it will be logged .
132,823
private static Object formatObject ( Object object ) { if ( object instanceof Class ) { return formatArg ( ( Class < ? > ) object ) ; } else if ( object instanceof Key ) { return formatArg ( ( Key < ? > ) object ) ; } else if ( object instanceof List ) { List < ? > list = ( List < ? > ) object ; boolean allDependencies...
Pretty - print a single object .
132,824
private String [ ] extractConstructorParameters ( Key < ? > factoryKey , TypeLiteral < ? > implementation , Constructor constructor , List < Key < ? > > methodParams , Errors errors , Set < Dependency > dependencyCollector ) throws ErrorsException { List < TypeLiteral < ? > > ctorParams = implementation . getParameterT...
Matches constructor parameters to method parameters for injection and records remaining parameters as required keys .
132,825
public void pruneInvalidOptional ( DependencyExplorerOutput output , InvalidKeys invalidKeys ) { DependencyGraph . GraphPruner prunedGraph = new DependencyGraph . GraphPruner ( output . getGraph ( ) ) ; for ( Key < ? > key : invalidKeys . getInvalidOptionalKeys ( ) ) { prunedGraph . remove ( key ) ; output . removeBind...
Prune all of the invalid optional keys from the graph . After this method all of the keys remaining in the graph are resolvable .
132,826
private Map < Key < ? > , String > getAllInvalidKeys ( DependencyExplorerOutput output ) { Map < Key < ? > , String > invalidKeys = new LinkedHashMap < Key < ? > , String > ( ) ; for ( Entry < Key < ? > , String > error : output . getBindingErrors ( ) ) { invalidKeys . put ( error . getKey ( ) , "Unable to create or in...
Returns a map from keys that are invalid to errors explaining why each key is invalid .
132,827
private Set < Key < ? > > getKeysToRemove ( DependencyGraph graph , Collection < Key < ? > > discovered ) { Set < Key < ? > > toRemove = new LinkedHashSet < Key < ? > > ( ) ; while ( ! discovered . isEmpty ( ) ) { toRemove . addAll ( discovered ) ; discovered = getRequiredSourcesTargeting ( graph , discovered ) ; disco...
Given the set of optional keys that had problems compute the set of all optional keys that should be removed . This may include additional keys for instance if an optional key requires an invalid key than the optional key should also be removed .
132,828
private Collection < Key < ? > > getRequiredSourcesTargeting ( DependencyGraph graph , Iterable < Key < ? > > targets ) { Collection < Key < ? > > requiredSources = new LinkedHashSet < Key < ? > > ( ) ; for ( Key < ? > target : targets ) { for ( Dependency edge : graph . getDependenciesTargeting ( target ) ) { if ( ! e...
Returns all of the source keys that have a required dependency on any key in the target set .
132,829
public Void visitScope ( Scope scope ) { messages . add ( new Message ( PrettyPrinter . format ( "Explicit scope unsupported: key=%s scope=%s" , targetKey , scope ) ) ) ; return null ; }
strange to be using the Guice Scope instead of javax . inject . Scope
132,830
public static String getUserPackageName ( TypeLiteral < ? > typeLiteral ) { Map < String , Class < ? > > packageNames = new LinkedHashMap < String , Class < ? > > ( ) ; getTypePackageNames ( typeLiteral . getType ( ) , packageNames ) ; if ( packageNames . size ( ) == 0 ) { return typeLiteral . getRawType ( ) . getPacka...
Return the name of the package from which the given type can be used .
132,831
private static void getClassPackageNames ( Class < ? > clazz , Map < String , Class < ? > > packageNames ) { if ( isPrivate ( clazz ) ) { throw new IllegalArgumentException ( PrettyPrinter . format ( "Unable to inject an instance of %s because it is a private class." , clazz ) ) ; } else if ( ! isPublic ( clazz ) ) { p...
Visits classes to collect package names .
132,832
private static void getParameterizedTypePackageNames ( ParameterizedType type , Map < String , Class < ? > > packageNames ) { for ( Type argumentType : type . getActualTypeArguments ( ) ) { getTypePackageNames ( argumentType , packageNames ) ; } getTypePackageNames ( type . getRawType ( ) , packageNames ) ; Type ownerT...
Visits parameterized types to collect package names .
132,833
private static void getTypeVariablePackageNames ( TypeVariable type , Map < String , Class < ? > > packageNames ) { for ( Type boundType : type . getBounds ( ) ) { getTypePackageNames ( boundType , packageNames ) ; } }
Visits type variables to collect package names .
132,834
private static void getWildcardTypePackageNames ( WildcardType type , Map < String , Class < ? > > packageNames ) { for ( Type boundType : type . getUpperBounds ( ) ) { getTypePackageNames ( boundType , packageNames ) ; } for ( Type boundType : type . getLowerBounds ( ) ) { getTypePackageNames ( boundType , packageName...
Visits wildcard types to collect package names .
132,835
public SourceSnippet getCreationStatements ( NameGenerator nameGenerator , List < InjectorMethod > methodsOutput ) throws NoSourceNameException { String moduleSourceName = ReflectUtil . getSourceName ( moduleType ) ; String createModule = "new " + moduleSourceName + "()" ; String type = ReflectUtil . getSourceName ( ta...
provider methods .
132,836
public String getGetterMethodPackage ( ) { Binding childBinding = childBindings . getBinding ( key ) ; if ( childBinding == null ) { errorManager . logError ( "No child binding found in %s for %s." , childBindings , key ) ; return "" ; } else { return childBinding . getGetterMethodPackage ( ) ; } }
The getter must be placed in the same package as the child getter to ensure that its return type is visible .
132,837
public String getGetterMethodPackage ( ) { Binding parentBinding = parentBindings . getBinding ( key ) ; if ( parentBinding == null ) { errorManager . logError ( "No parent binding found in %s for %s." , parentBindings , key ) ; return "" ; } else { return parentBinding . getGetterMethodPackage ( ) ; } }
The getter must be placed in the same package as the parent getter to ensure that its return type is visible .
132,838
public GinjectorBindings getInstallPosition ( Key < ? > key ) { Preconditions . checkNotNull ( positions , "Must call position before calling getInstallPosition(Key<?>)" ) ; GinjectorBindings position = installOverrides . get ( key ) ; if ( position == null ) { position = positions . get ( key ) ; } return position ; }
Returns the Ginjector where the binding for key should be placed or null if the key was removed from the dependency graph earlier .
132,839
private void computeInitialPositions ( ) { positions . putAll ( output . getPreExistingLocations ( ) ) ; for ( Key < ? > key : output . getImplicitlyBoundKeys ( ) ) { GinjectorBindings initialPosition = computeInitialPosition ( key ) ; PrettyPrinter . log ( logger , TreeLogger . DEBUG , PrettyPrinter . format ( "Initia...
Place an initial guess in the position map that places each implicit binding as high as possible in the injector tree without causing double binding .
132,840
private GinjectorBindings computeInitialPosition ( Key < ? > key ) { GinjectorBindings initialPosition = output . getGraph ( ) . getOrigin ( ) ; boolean pinned = initialPosition . isPinned ( key ) ; if ( pinned ) { PrettyPrinter . log ( logger , TreeLogger . DEBUG , PrettyPrinter . format ( "Forcing %s to be installed ...
Returns the highest injector that we could possibly position the key at without causing a double binding .
132,841
private boolean canExposeKeyFrom ( Key < ? > key , GinjectorBindings child , boolean pinned ) { GinjectorBindings parent = child . getParent ( ) ; if ( parent == null ) { return false ; } else if ( parent . isBoundLocallyInChild ( key ) ) { return false ; } else if ( pinned ) { Binding binding = parent . getBinding ( k...
Tests whether a key from the given child injector can be made visible in its parent . For pinned keys this means that they re exposed to the parent ; for keys that aren t pinned it means that there s no other constraint preventing them from floating up .
132,842
private void calculateExactPositions ( ) { while ( ! workqueue . isEmpty ( ) ) { Key < ? > key = workqueue . iterator ( ) . next ( ) ; workqueue . remove ( key ) ; Set < GinjectorBindings > injectors = getSourceGinjectors ( key ) ; injectors . add ( positions . get ( key ) ) ; GinjectorBindings newPosition = lowest ( i...
Iterates on the position equation updating each binding in the queue and re - queueing nodes that depend on any node we move . This will always terminate since we only re - queue when we make a change and there are a finite number of entries in the injector hierarchy .
132,843
private Set < GinjectorBindings > getSourceGinjectors ( Key < ? > key ) { Set < GinjectorBindings > sourceInjectors = new LinkedHashSet < GinjectorBindings > ( ) ; for ( Dependency dep : output . getGraph ( ) . getDependenciesOf ( key ) ) { sourceInjectors . add ( positions . get ( dep . getTarget ( ) ) ) ; } return so...
Returns the injectors where the dependencies for node are currently placed .
132,844
public static SourceSnippet callChildGetter ( final GinjectorBindings childBindings , final Key < ? > key ) { return new SourceSnippet ( ) { public String getSource ( InjectorWriteContext writeContext ) { return writeContext . callChildGetter ( childBindings , key ) ; } } ; }
Creates a snippet that evaluates to an injected instance of the given key as produced by the given child .
132,845
public static SourceSnippet callMethod ( final String methodName , final String fragmentPackageName , final Iterable < String > parameters ) { return new SourceSnippet ( ) { public String getSource ( InjectorWriteContext writeContext ) { return writeContext . callMethod ( methodName , fragmentPackageName , parameters )...
Creates a snippet that evaluates to an invocation of the named method on the given package fragment .
132,846
public static SourceSnippet callParentGetter ( final Key < ? > key , final GinjectorBindings parentBindings ) { return new SourceSnippet ( ) { public String getSource ( InjectorWriteContext writeContext ) { return writeContext . callParentGetter ( key , parentBindings ) ; } } ; }
Creates a snippet that evaluates to an injected instance of the given key as produced by the given parent injector .
132,847
public static SourceSnippet forText ( final String text ) { return new SourceSnippet ( ) { public String getSource ( InjectorWriteContext writeContext ) { return text ; } } ; }
Creates a snippet that generates a constant text string .
132,848
public String getFragmentClassName ( String injectorClassName , FragmentPackageName fragmentPackageName ) { Preconditions . checkArgument ( ! injectorClassName . contains ( "." ) , "The injector class must be a simple name, but it was \"%s\"" , injectorClassName ) ; return injectorClassName + "_fragment" ; }
Computes the name of a single fragment of a Ginjector .
132,849
public static String replaceLast ( String source , char toReplace , char with ) { StringBuilder sb = new StringBuilder ( source ) ; int index = sb . lastIndexOf ( String . valueOf ( toReplace ) ) ; if ( index != - 1 ) { sb . setCharAt ( index , with ) ; } return sb . toString ( ) ; }
Static for access from enum .
132,850
public DependencyExplorerOutput explore ( GinjectorBindings origin ) { DependencyExplorerOutput output = new DependencyExplorerOutput ( ) ; DependencyGraph . Builder builder = new DependencyGraph . Builder ( origin ) ; for ( Dependency edge : origin . getDependencies ( ) ) { Preconditions . checkState ( Dependency . GI...
Explore the unresolved dependencies in the origin Ginjector and create the corresponding dependency graph . Also gathers information about key in the dependency graph such as which Ginjector it is already available on or what implicit binding was created for it .
132,851
private GinjectorBindings locateHighestAccessibleSource ( Key < ? > key , GinjectorBindings origin ) { if ( ! origin . isBound ( key ) && origin . isPinned ( key ) ) { return null ; } GinjectorBindings source = null ; for ( GinjectorBindings iter = origin ; iter != null ; iter = iter . getParent ( ) ) { if ( iter . isB...
Find the highest binding in the Ginjector tree that could be used to supply the given key .
132,852
public boolean findAndReportCycles ( DependencyGraph graph ) { this . graph = graph ; cycleDetected = false ; visitedEdge = new LinkedHashMap < Key < ? > , Dependency > ( graph . size ( ) ) ; for ( Key < ? > key : graph . getAllKeys ( ) ) { visit ( key , null ) ; } return cycleDetected ; }
Detects cycles in the given graph .
132,853
static List < Dependency > rootCycleAt ( List < Dependency > cycle , Key < ? > key ) { for ( int i = 0 ; i < cycle . size ( ) ; ++ i ) { if ( key . equals ( cycle . get ( i ) . getSource ( ) ) ) { List < Dependency > returnValue = new ArrayList < Dependency > ( ) ; returnValue . addAll ( cycle . subList ( i , cycle . s...
Attempts to root the given dependency cycle at the given key . If the key is present in the cycle rotates the dependency cycle so that the key is the first source . Otherwise returns the cycle unchanged .
132,854
public List < TypeLiteral < ? > > getParameterTypes ( ) { if ( parameterTypes == null ) { parameterTypes = getDeclaringType ( ) . getParameterTypes ( getMember ( ) ) ; } return parameterTypes ; }
Returns this method s parameter types if appropriate parametrized with the declaring class s type parameters .
132,855
private ClassLoader createGinClassLoader ( TreeLogger logger , GeneratorContext context ) { Set < String > exceptions = new LinkedHashSet < String > ( ) ; exceptions . add ( "com.google.inject" ) ; exceptions . add ( "javax.inject" ) ; exceptions . add ( "com.google.gwt.inject.client" ) ; exceptions . add ( "com.google...
Creates a new gin - specific class loader that will load GWT and non - GWT types such that there is never a conflict especially with super source .
132,856
Class < ? > loadClass ( String requestedClass , boolean initialize ) throws ClassNotFoundException { String binaryName = requestedClass ; while ( true ) { try { return Class . forName ( binaryName , initialize , classLoader ) ; } catch ( ClassNotFoundException e ) { if ( ! binaryName . contains ( "." ) ) { throw e ; } ...
Package accessible for testing .
132,857
void write ( GinjectorBindings bindings ) throws UnableToCompleteException { TypeLiteral < ? > ginjectorInterface = bindings . getGinjectorInterface ( ) ; String implClassName = ginjectorNameGenerator . getClassName ( bindings ) ; if ( implClassName . contains ( "." ) ) { errorManager . logError ( "Internal error: the ...
Writes the Ginjector class for the given bindings object and all its package - specific fragments .
132,858
private void outputInterfaceField ( GinjectorBindings bindings , SourceWriteUtil sourceWriteUtil , SourceWriter writer ) { if ( bindings . getParent ( ) != null ) { return ; } Class < ? > boundGinjectorInterface = getBoundGinjector ( bindings ) ; if ( boundGinjectorInterface == null ) { errorManager . logError ( "Injec...
Writes code to store and retrieve the current injector interface if one is bound .
132,859
private void outputMemberInjections ( GinjectorBindings bindings , FragmentMap fragments , SourceWriteUtil sourceWriteUtil ) { NameGenerator nameGenerator = bindings . getNameGenerator ( ) ; for ( TypeLiteral < ? > type : bindings . getMemberInjectRequests ( ) ) { if ( ! reachabilityAnalyzer . isReachableMemberInject (...
Adds member injections to each fragment .
132,860
void outputStaticInjectionMethods ( Class < ? > type , FragmentMap fragments , NameGenerator nameGenerator , SourceWriteUtil sourceWriteUtil ) { String methodName = nameGenerator . convertToValidMemberName ( "injectStatic_" + type . getName ( ) ) ; SourceSnippetBuilder body = new SourceSnippetBuilder ( ) ; for ( Inject...
Outputs all the static injection methods for the given class .
132,861
void outputMethods ( Iterable < InjectorMethod > methods , FragmentMap fragments ) { for ( InjectorMethod method : methods ) { FragmentPackageName fragmentPackageName = fragmentPackageNameFactory . create ( method . getPackageName ( ) ) ; GinjectorFragmentOutputter fragment = fragments . get ( fragmentPackageName ) ; f...
Outputs some methods to the fragments they belong to .
132,862
private static Class < ? > getBoundGinjector ( GinjectorBindings bindings ) { if ( bindings . getGinjectorInterface ( ) == null ) { return null ; } TypeLiteral < ? > ginjectorInterface = bindings . getGinjectorInterface ( ) ; Key < ? > ginjectorKey = Key . get ( ginjectorInterface ) ; if ( ! bindings . isBound ( ginjec...
Gets the Ginjector interface that is bound by the given bindings if any .
132,863
void writeBindingGetter ( Key < ? > key , Binding binding , GinScope scope , List < InjectorMethod > helperMethodsOutput ) { Context bindingContext = binding . getContext ( ) ; SourceSnippetBuilder getterBuilder = new SourceSnippetBuilder ( ) ; SourceSnippet creationStatements ; String getter = nameGenerator . getGette...
Writes a method describing the getter for the given key along with any other code necessary to support it . Produces a list of helper methods that still need to be written .
132,864
void commit ( ) { if ( committed ) { errorManager . logError ( "Committed the fragment for %s twice." , fragmentPackageName ) ; return ; } committed = true ; writer . beginJavaDocComment ( ) ; writer . print ( "Field for the enclosing injector." ) ; writer . endJavaDocComment ( ) ; writer . println ( "private final %s ...
Outputs all the top - level methods and fields of the class and commits the writer . Must be the last method invoked on this object .
132,865
private void registerGinjectorBinding ( ) { Key < ? extends Ginjector > ginjectorKey = Key . get ( ginjectorInterface ) ; rootGinjectorBindings . addBinding ( ginjectorKey , bindingFactory . getGinjectorBinding ( ) ) ; }
Create an explicit binding for the Ginjector .
132,866
private void resolveAllUnresolvedBindings ( GinjectorBindings collection ) throws UnableToCompleteException { createBindingsForFactories ( collection ) ; for ( GinjectorBindings child : collection . getChildren ( ) ) { resolveAllUnresolvedBindings ( child ) ; } collection . resolveBindings ( ) ; }
Create bindings for factories and resolve all implicit bindings for all unresolved bindings in the each injector .
132,867
public SourceSnippet createFieldInjection ( final FieldLiteral < ? > field , final String injecteeName , NameGenerator nameGenerator , List < InjectorMethod > methodsOutput ) throws NoSourceNameException { final boolean hasInjectee = injecteeName != null ; final boolean useNativeMethod = field . isPrivate ( ) || Reflec...
Creates a field injecting method and returns a string that invokes the written method .
132,868
public void writeBindingContext ( SourceWriter writer , Context context ) { String text = context . toString ( ) ; boolean first = true ; for ( String line : text . split ( "\n" ) ) { if ( first ) { first = false ; } else { writer . println ( ) ; } writer . print ( " " ) ; writer . print ( line ) ; } }
Writes out a binding context followed by a newline .
132,869
public void writeBindingContextJavadoc ( SourceWriter writer , Context bindingContext , String description ) { writer . beginJavaDocComment ( ) ; writer . println ( description ) ; writeBindingContext ( writer , bindingContext ) ; writer . endJavaDocComment ( ) ; }
Write a Javadoc comment for a binding including its context .
132,870
public void writeBindingContextJavadoc ( SourceWriter writer , Context bindingContext , Key < ? > key ) { writeBindingContextJavadoc ( writer , bindingContext , "Binding for " + key . getTypeLiteral ( ) + " declared at:" ) ; }
Write the Javadoc for the binding of a particular key showing the context of the binding .
132,871
public void writeMethod ( SourceWriter writer , String signature , String body ) { writer . println ( signature + " {" ) ; writer . indent ( ) ; writer . println ( body ) ; writer . outdent ( ) ; writer . println ( "}" ) ; writer . println ( ) ; }
Writes a method with the given signature and body to the source writer .
132,872
public void writeMethod ( InjectorMethod method , SourceWriter writer , InjectorWriteContext writeContext ) throws NoSourceNameException { if ( method . isNative ( ) ) { writeNativeMethod ( writer , method . getMethodSignature ( ) , method . getMethodBody ( writeContext ) ) ; } else { writeMethod ( writer , method . ge...
Writes the given method to the given source writer .
132,873
public void writeMethods ( Iterable < InjectorMethod > methods , SourceWriter writer , InjectorWriteContext writeContext ) throws NoSourceNameException { for ( InjectorMethod method : methods ) { writeMethod ( method , writer , writeContext ) ; } }
Writes the given methods to the given source writer .
132,874
public String createMemberInjection ( TypeLiteral < ? > type , NameGenerator nameGenerator , List < InjectorMethod > methodsOutput ) throws NoSourceNameException { String memberInjectMethodName = nameGenerator . getMemberInjectMethodName ( type ) ; String memberInjectMethodSignature = "public void " + memberInjectMetho...
Generates all the required injector methods to inject members of the given type and a standard member - inject method that invokes them .
132,875
public SourceSnippet createConstructorInjection ( MethodLiteral < ? , Constructor < ? > > constructor , NameGenerator nameGenerator , List < InjectorMethod > methodsOutput ) throws NoSourceNameException { return createMethodCallWithInjection ( constructor , null , nameGenerator , methodsOutput ) ; }
Creates a constructor injecting method and returns a string that invokes the new method . The new method returns the constructed object .
132,876
public SourceSnippet createMethodCallWithInjection ( MethodLiteral < ? , ? > method , String invokeeName , NameGenerator nameGenerator , List < InjectorMethod > methodsOutput ) throws NoSourceNameException { String [ ] params = new String [ method . getParameterTypes ( ) . size ( ) ] ; return createMethodCallWithInject...
Creates a method that calls the passed method injecting its parameters using getters and returns a string that invokes the new method . The new method returns the passed method s return value if any . If a method without parameters is provided that method will be called and no parameters will be passed .
132,877
private boolean isLongAccess ( MethodLiteral < ? , ? > method ) { boolean result = method . getReturnType ( ) . getRawType ( ) . equals ( Long . TYPE ) ; for ( TypeLiteral < ? > paramLiteral : method . getParameterTypes ( ) ) { result |= paramLiteral . getRawType ( ) . equals ( Long . TYPE ) ; } return result ; }
Check whether a method needs to have Long access .
132,878
protected Class < ? > findClass ( String name ) throws ClassNotFoundException { if ( ! loadedClassFiles ) { classFileMap = extractClassFileMap ( ) ; loadedClassFiles = true ; } if ( classFileMap == null ) { throw new ClassNotFoundException ( name ) ; } String internalName = name . replace ( '.' , '/' ) ; CompiledClass ...
Looks up classes in GWT s compilation state .
132,879
public Binding create ( Key < ? > key ) throws BindingCreationException { TypeLiteral < ? > type = key . getTypeLiteral ( ) ; if ( isProviderKey ( key ) ) { return bindingFactory . getImplicitProviderBinding ( key ) ; } if ( isAsyncProviderKey ( key ) ) { return bindingFactory . getAsyncProviderBinding ( key ) ; } if (...
Creates the implicit binding .
132,880
private void traceGinjectorMethods ( ) { TypeLiteral < ? > ginjectorInterface = rootBindings . getGinjectorInterface ( ) ; for ( MethodLiteral < ? , Method > method : memberCollector . getMethods ( ginjectorInterface ) ) { if ( ! guiceUtil . isMemberInject ( method ) ) { Key < ? > key = guiceUtil . getKey ( method ) ; ...
Traces out bindings that are reachable from a GInjector method .
132,881
private String getNameForType ( Class < ? > type ) { if ( _typeToStringMap . containsKey ( type ) ) { return _typeToStringMap . get ( type ) ; } for ( Entry < String , Class < ? > > entry : _typeMappings . entrySet ( ) ) { if ( entry . getValue ( ) . isAssignableFrom ( type ) ) { return entry . getKey ( ) ; } } return ...
given a type get a name . This takes subclassing into consideration . For now this will return the first subclass match to the type not the closest
132,882
public static ProxyInfo setProxyCfg ( String host , String port , String userName , String password ) { return new ProxyInfo ( host , port , userName , password ) ; }
Set proxy configuration .
132,883
@ SuppressWarnings ( "squid:S134" ) private void createHtmlReport ( FilePath reportFolder , String testFolderPath , File artifactsDir , List < String > reportNames , TestResult testResult ) throws IOException , InterruptedException { String archiveTestResultMode = _resultsPublisherModel . getArchiveTestResultsMode ( ) ...
Copy Summary Html reports created by LoadRunner
132,884
private void createTransactionSummary ( FilePath reportFolder , String testFolderPath , File artifactsDir , List < String > reportNames , TestResult testResult ) throws IOException , InterruptedException { File testFolderPathFile = new File ( testFolderPath ) ; String subFolder = HTML_REPORT_FOLDER + File . separator +...
Copies and creates the transaction summery on the master
132,885
private void setProxyCredentials ( Run < ? , ? > run ) { if ( proxySettings != null && proxySettings . getFsProxyCredentialsId ( ) != null ) { UsernamePasswordCredentials up = CredentialsProvider . findCredentialById ( proxySettings . getFsProxyCredentialsId ( ) , StandardUsernamePasswordCredentials . class , run , URI...
Get credentials by the credentials id . Then set the user name and password into the SsePoxySetting .
132,886
private UsernamePasswordCredentials getCredentialsById ( String credentialsId , Run < ? , ? > run , PrintStream logger ) { if ( StringUtils . isBlank ( credentialsId ) ) { throw new NullPointerException ( "credentials is not configured." ) ; } UsernamePasswordCredentials credentials = CredentialsProvider . findCredenti...
Get user name password credentials by id .
132,887
public void mergeResults ( LrJobResults resultFiles ) { for ( JobLrScenarioResult scenarioResult : resultFiles . getLrScenarioResults ( ) . values ( ) ) { this . _resultFiles . addScenario ( scenarioResult ) ; } }
Merge results of several runs - espcially useful in pipeline jobs with multiple LR steps
132,888
public JSONObject loginToMC ( String mcUrl , String mcUserName , String mcPassword , String proxyAddress , String proxyUsername , String proxyPassword ) { JSONObject returnObject = new JSONObject ( ) ; try { Map < String , String > headers = new HashMap < String , String > ( ) ; headers . put ( Constants . ACCEPT , "ap...
Login to MC
132,889
public JSONObject upload ( String mcUrl , String mcUserName , String mcPassword , String proxyAddress , String proxyUsername , String proxyPassword , String appPath ) throws Exception { JSONObject json = null ; String hp4mSecret = null ; String jsessionId = null ; File appFile = new File ( appPath ) ; String uploadUrl ...
upload app to MC
132,890
public String createTempJob ( String mcUrl , String mcUserName , String mcPassword , String proxyAddress , String proxyUserName , String proxyPassword ) { JSONObject job = null ; String jobId = null ; String hp4mSecret = null ; String jsessionId = null ; String loginJson = loginToMC ( mcUrl , mcUserName , mcPassword , ...
create one temp job
132,891
public JSONObject getJobById ( String mcUrl , String mcUserName , String mcPassword , String proxyAddress , String proxyUsername , String proxyPassword , String jobUUID ) { JSONObject jobJsonObject = null ; String hp4mSecret = null ; String jsessionId = null ; String loginJson = loginToMC ( mcUrl , mcUserName , mcPassw...
get one job by id
132,892
public List < Result . Suites > getSuites ( ) { if ( suites == null ) { suites = new ArrayList < Result . Suites > ( ) ; } return this . suites ; }
Gets the value of the suites property .
132,893
public MCServerSettingsModel getMCServerSettingsModel ( ) { for ( MCServerSettingsModel mcServer : getDescriptor ( ) . getMcServers ( ) ) { if ( this . runFromFileModel != null && runFromFileModel . getMcServerName ( ) != null && mcServer . getMcServerName ( ) != null && runFromFileModel . getMcServerName ( ) . equals ...
Gets mc server settings model .
132,894
static void constructPercentileTransactionGraph ( Map . Entry < String , LrProjectScenarioResults > scenarioResults , JSONObject scenarioGraphData ) { Map < Integer , TreeMap < String , PercentileTransactionWholeRun > > percentileTransactionResults = scenarioResults . getValue ( ) . getPercentileTransactionResults ( ) ...
creates dataset for Percentile transaction graph
132,895
static void constructAvgTransactionGraph ( Map . Entry < String , LrProjectScenarioResults > scenarioResults , JSONObject scenarioGraphData ) { Map < Integer , TreeMap < String , AvgTransactionResponseTime > > avgTransactionResponseTimeResults = scenarioResults . getValue ( ) . getAvgTransactionResponseTimeResults ( ) ...
Construct avg transaction graph .
132,896
static void constructErrorGraph ( Map . Entry < String , LrProjectScenarioResults > scenarioResults , JSONObject scenarioGraphData ) { Map < Integer , TimeRangeResult > errPerSecResults = scenarioResults . getValue ( ) . getErrPerSecResults ( ) ; JSONObject errPerSecResultsResultsGraphSet = extractTimeRangeResult ( err...
Construct error graph .
132,897
static void constructAverageThroughput ( Map . Entry < String , LrProjectScenarioResults > scenarioResults , JSONObject scenarioGraphData ) { Map < Integer , WholeRunResult > averageThroughputResults = scenarioResults . getValue ( ) . getAverageThroughputResults ( ) ; JSONObject averageThroughputResultsGraphSet = extra...
Construct average throughput .
132,898
static void constructTotalThroughputGraph ( Map . Entry < String , LrProjectScenarioResults > scenarioResults , JSONObject scenarioGraphData ) { Map < Integer , WholeRunResult > totalThroughputResults = scenarioResults . getValue ( ) . getTotalThroughtputResults ( ) ; JSONObject totalThroughputResultsGraphSet = extract...
Construct total throughput graph .
132,899
static void constructAvgHitsGraph ( Map . Entry < String , LrProjectScenarioResults > scenarioResults , JSONObject scenarioGraphData ) { Map < Integer , WholeRunResult > avgHitsPerSec = scenarioResults . getValue ( ) . getAverageHitsPerSecondResults ( ) ; JSONObject avgHitsPerSecGraphSet = extractWholeRunSlaResult ( av...
Construct avg hits graph .