idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
140,200
public static SessionManagerException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionManagerException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionManagerException ) cause : new SessionManagerException ( message , cause ) ; }
Converts a Throwable to a SessionManagerException with the specified detail message . If the Throwable is a SessionManagerException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionManagerException with the detail message .
59
64
140,201
public static InvalidFormulaInContextException fromThrowable ( Throwable cause ) { return ( cause instanceof InvalidFormulaInContextException ) ? ( InvalidFormulaInContextException ) cause : new InvalidFormulaInContextException ( cause ) ; }
Converts a Throwable to a InvalidFormulaInContextException . If the Throwable is a InvalidFormulaInContextException it will be passed through unmodified ; otherwise it will be wrapped in a new InvalidFormulaInContextException .
52
49
140,202
public static InvalidFormulaInContextException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof InvalidFormulaInContextException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( InvalidFormulaInContextException ) cause : new InvalidFormulaInContextException ( message , cause ) ; }
Converts a Throwable to a InvalidFormulaInContextException with the specified detail message . If the Throwable is a InvalidFormulaInContextException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new InvalidFormulaInContextException with the detail message .
71
73
140,203
public static InvalidNameException fromThrowable ( Throwable cause ) { return ( cause instanceof InvalidNameException ) ? ( InvalidNameException ) cause : new InvalidNameException ( cause ) ; }
Converts a Throwable to a InvalidNameException . If the Throwable is a InvalidNameException it will be passed through unmodified ; otherwise it will be wrapped in a new InvalidNameException .
40
40
140,204
public static InvalidNameException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof InvalidNameException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( InvalidNameException ) cause : new InvalidNameException ( message , cause ) ; }
Converts a Throwable to a InvalidNameException with the specified detail message . If the Throwable is a InvalidNameException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new InvalidNameException with the detail message .
59
64
140,205
public static SessionConfigurationException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionConfigurationException ) ? ( SessionConfigurationException ) cause : new SessionConfigurationException ( cause ) ; }
Converts a Throwable to a SessionConfigurationException . If the Throwable is a SessionConfigurationException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionConfigurationException .
40
40
140,206
public static SessionConfigurationException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionConfigurationException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionConfigurationException ) cause : new SessionConfigurationException ( message , cause ) ; }
Converts a Throwable to a SessionConfigurationException with the specified detail message . If the Throwable is a SessionConfigurationException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionConfigurationException with the detail message .
59
64
140,207
public static SessionInitializationException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionInitializationException ) ? ( SessionInitializationException ) cause : new SessionInitializationException ( cause ) ; }
Converts a Throwable to a SessionInitializationException . If the Throwable is a SessionInitializationException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionInitializationException .
44
43
140,208
public static SessionInitializationException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionInitializationException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionInitializationException ) cause : new SessionInitializationException ( message , cause ) ; }
Converts a Throwable to a SessionInitializationException with the specified detail message . If the Throwable is a SessionInitializationException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionInitializationException with the detail message .
63
67
140,209
public static SessionException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionException ) ? ( SessionException ) cause : new SessionException ( cause ) ; }
Converts a Throwable to a SessionException . If the Throwable is a SessionException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionException .
36
37
140,210
public static SessionException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionException ) cause : new SessionException ( message , cause ) ; }
Converts a Throwable to a SessionException with the specified detail message . If the Throwable is a SessionException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionException with the detail message .
55
61
140,211
public static VariableArityException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof VariableArityException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( VariableArityException ) cause : new VariableArityException ( message , cause ) ; }
Converts a Throwable to a VariableArityException with the specified detail message . If the Throwable is a VariableArityException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new VariableArityException with the detail message .
63
67
140,212
public static KbObjectNotFoundException fromThrowable ( Throwable cause ) { return ( cause instanceof KbObjectNotFoundException ) ? ( KbObjectNotFoundException ) cause : new KbObjectNotFoundException ( cause ) ; }
Converts a Throwable to a KbObjectNotFoundException . If the Throwable is a KbObjectNotFoundException it will be passed through unmodified ; otherwise it will be wrapped in a new KbObjectNotFoundException .
52
49
140,213
public static KbObjectNotFoundException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof KbObjectNotFoundException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( KbObjectNotFoundException ) cause : new KbObjectNotFoundException ( message , cause ) ; }
Converts a Throwable to a KbObjectNotFoundException with the specified detail message . If the Throwable is a KbObjectNotFoundException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new KbObjectNotFoundException with the detail message .
71
73
140,214
public static KbRuntimeException fromThrowable ( Throwable cause ) { return ( cause instanceof KbRuntimeException ) ? ( KbRuntimeException ) cause : new KbRuntimeException ( cause ) ; }
Converts a Throwable to a KbRuntimeException . If the Throwable is a KbRuntimeException it will be passed through unmodified ; otherwise it will be wrapped in a new KbRuntimeException .
44
43
140,215
public static KbRuntimeException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof KbRuntimeException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( KbRuntimeException ) cause : new KbRuntimeException ( message , cause ) ; }
Converts a Throwable to a KbRuntimeException with the specified detail message . If the Throwable is a KbRuntimeException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new KbRuntimeException with the detail message .
63
67
140,216
public static StaleKbObjectException fromThrowable ( Throwable cause ) { return ( cause instanceof StaleKbObjectException ) ? ( StaleKbObjectException ) cause : new StaleKbObjectException ( cause ) ; }
Converts a Throwable to a StaleKbObjectException . If the Throwable is a StaleKbObjectException it will be passed through unmodified ; otherwise it will be wrapped in a new StaleKbObjectException .
52
49
140,217
public static StaleKbObjectException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof StaleKbObjectException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( StaleKbObjectException ) cause : new StaleKbObjectException ( message , cause ) ; }
Converts a Throwable to a StaleKbObjectException with the specified detail message . If the Throwable is a StaleKbObjectException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new StaleKbObjectException with the detail message .
71
73
140,218
public static OpenCycUnsupportedFeatureException fromThrowable ( Throwable cause ) { return ( cause instanceof OpenCycUnsupportedFeatureException ) ? ( OpenCycUnsupportedFeatureException ) cause : new OpenCycUnsupportedFeatureException ( cause ) ; }
Converts a Throwable to a OpenCycUnsupportedFeatureException . If the Throwable is a OpenCycUnsupportedFeatureException it will be passed through unmodified ; otherwise it will be wrapped in a new OpenCycUnsupportedFeatureException .
56
52
140,219
public static OpenCycUnsupportedFeatureException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof OpenCycUnsupportedFeatureException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( OpenCycUnsupportedFeatureException ) cause : new OpenCycUnsupportedFeatureException ( message , cause ) ; }
Converts a Throwable to a OpenCycUnsupportedFeatureException with the specified detail message . If the Throwable is a OpenCycUnsupportedFeatureException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new OpenCycUnsupportedFeatureException with the detail message .
75
76
140,220
public static CreateException fromThrowable ( Throwable cause ) { return ( cause instanceof CreateException ) ? ( CreateException ) cause : new CreateException ( cause ) ; }
Converts a Throwable to a CreateException . If the Throwable is a CreateException it will be passed through unmodified ; otherwise it will be wrapped in a new CreateException .
36
37
140,221
public static CreateException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof CreateException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( CreateException ) cause : new CreateException ( message , cause ) ; }
Converts a Throwable to a CreateException with the specified detail message . If the Throwable is a CreateException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new CreateException with the detail message .
55
61
140,222
public static SessionManagerConfigurationException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionManagerConfigurationException ) ? ( SessionManagerConfigurationException ) cause : new SessionManagerConfigurationException ( cause ) ; }
Converts a Throwable to a SessionManagerConfigurationException . If the Throwable is a SessionManagerConfigurationException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionManagerConfigurationException .
44
43
140,223
public static SessionManagerConfigurationException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionManagerConfigurationException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionManagerConfigurationException ) cause : new SessionManagerConfigurationException ( message , cause ) ; }
Converts a Throwable to a SessionManagerConfigurationException with the specified detail message . If the Throwable is a SessionManagerConfigurationException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionManagerConfigurationException with the detail message .
63
67
140,224
private static boolean isAPortOffset ( int offset ) { return ( offset == STANDARD_ASCII_PORT_OFFSET ) || ( offset == STANDARD_HTTP_PORT_OFFSET ) || ( offset == STANDARD_SERVLET_PORT_OFFSET ) || ( offset == STANDARD_CFASL_PORT_OFFSET ) ; }
Tests whether an int is a known port offset .
75
11
140,225
public static SessionCommandException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionCommandException ) ? ( SessionCommandException ) cause : new SessionCommandException ( cause ) ; }
Converts a Throwable to a SessionCommandException . If the Throwable is a SessionCommandException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionCommandException .
40
40
140,226
public static SessionCommandException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionCommandException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionCommandException ) cause : new SessionCommandException ( message , cause ) ; }
Converts a Throwable to a SessionCommandException with the specified detail message . If the Throwable is a SessionCommandException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionCommandException with the detail message .
59
64
140,227
public static UnsupportedCycOperationException fromThrowable ( Throwable cause ) { return ( cause instanceof UnsupportedCycOperationException ) ? ( UnsupportedCycOperationException ) cause : new UnsupportedCycOperationException ( cause ) ; }
Converts a Throwable to a UnsupportedCycOperationException . If the Throwable is a UnsupportedCycOperationException it will be passed through unmodified ; otherwise it will be wrapped in a new UnsupportedCycOperationException .
52
49
140,228
public static UnsupportedCycOperationException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof UnsupportedCycOperationException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( UnsupportedCycOperationException ) cause : new UnsupportedCycOperationException ( message , cause ) ; }
Converts a Throwable to a UnsupportedCycOperationException with the specified detail message . If the Throwable is a UnsupportedCycOperationException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new UnsupportedCycOperationException with the detail message .
71
73
140,229
public static void unregisterActivityLifecycleCallbacks ( Application application , ActivityLifecycleCallbacksCompat callback ) { if ( PRE_ICS ) { preIcsUnregisterActivityLifecycleCallbacks ( callback ) ; } else { postIcsUnregisterActivityLifecycleCallbacks ( application , callback ) ; } }
Unregisters a previously registered callback .
69
8
140,230
public static SessionRuntimeException fromThrowable ( Throwable cause ) { return ( cause instanceof SessionRuntimeException ) ? ( SessionRuntimeException ) cause : new SessionRuntimeException ( cause ) ; }
Converts a Throwable to a SessionRuntimeException . If the Throwable is a SessionRuntimeException it will be passed through unmodified ; otherwise it will be wrapped in a new SessionRuntimeException .
40
40
140,231
public static SessionRuntimeException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof SessionRuntimeException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( SessionRuntimeException ) cause : new SessionRuntimeException ( message , cause ) ; }
Converts a Throwable to a SessionRuntimeException with the specified detail message . If the Throwable is a SessionRuntimeException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new SessionRuntimeException with the detail message .
59
64
140,232
protected ByteSource stream ( final String resourceId ) { return new ByteSource ( ) { @ Override public InputStream openStream ( ) throws IOException { return loader . getResource ( resourceId ) . getInputStream ( ) ; } } ; }
Wouldn t it be nice if we wrote some tests?
52
12
140,233
public static QueryRuntimeException fromThrowable ( Throwable t ) { return ( t instanceof QueryRuntimeException ) ? ( QueryRuntimeException ) t : new QueryRuntimeException ( t ) ; }
Converts a Throwable to a QueryRuntimeException . If the Throwable is a QueryRuntimeException it will be passed through unmodified ; otherwise it will be wrapped in a new QueryRuntimeException .
40
40
140,234
public static QueryRuntimeException fromThrowable ( String message , Throwable t ) { return ( t instanceof QueryRuntimeException && Objects . equals ( message , t . getMessage ( ) ) ) ? ( QueryRuntimeException ) t : new QueryRuntimeException ( message , t ) ; }
Converts a Throwable to a QueryRuntimeException with the specified detail message . If the Throwable is a QueryRuntimeException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new QueryRuntimeException with the detail message .
59
64
140,235
public static ProofViewException fromThrowable ( Throwable cause ) { return ( cause instanceof ProofViewException ) ? ( ProofViewException ) cause : new ProofViewException ( cause ) ; }
Converts a Throwable to a ProofViewException . If the Throwable is a ProofViewException it will be passed through unmodified ; otherwise it will be wrapped in a new ProofViewException .
40
40
140,236
public static ProofViewException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof ProofViewException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( ProofViewException ) cause : new ProofViewException ( message , cause ) ; }
Converts a Throwable to a ProofViewException with the specified detail message . If the Throwable is a ProofViewException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new ProofViewException with the detail message .
59
64
140,237
public static KbException fromThrowable ( Throwable cause ) { return ( cause instanceof KbException ) ? ( KbException ) cause : new KbException ( cause ) ; }
Converts a Throwable to a KbException . If the Throwable is a KbException it will be passed through unmodified ; otherwise it will be wrapped in a new KbException .
40
40
140,238
public static KbException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof KbException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( KbException ) cause : new KbException ( message , cause ) ; }
Converts a Throwable to a KbException with the specified detail message . If the Throwable is a KbException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new KbException with the detail message .
59
64
140,239
public static DeleteException fromThrowable ( Throwable cause ) { return ( cause instanceof DeleteException ) ? ( DeleteException ) cause : new DeleteException ( cause ) ; }
Converts a Throwable to a DeleteException . If the Throwable is a DeleteException it will be passed through unmodified ; otherwise it will be wrapped in a new DeleteException .
36
37
140,240
public static DeleteException fromThrowable ( String message , Throwable cause ) { return ( cause instanceof DeleteException && Objects . equals ( message , cause . getMessage ( ) ) ) ? ( DeleteException ) cause : new DeleteException ( message , cause ) ; }
Converts a Throwable to a DeleteException with the specified detail message . If the Throwable is a DeleteException and if the Throwable s message is identical to the one supplied the Throwable will be passed through unmodified ; otherwise it will be wrapped in a new DeleteException with the detail message .
55
61
140,241
@ PostConstruct public void initialize ( ) { if ( this . initializationState . setInitializing ( ) ) { if ( this . visibility == null ) { this . visibility = VisibilityModifier . PUBLIC ; } this . initializationState . setInitialized ( ) ; } }
This method initializes this class . It has to be called after construction and injection is completed .
56
19
140,242
public List < ModuleBuildFuture > getExtraBuilds ( ) { return extraBuilds == null ? Collections . < ModuleBuildFuture > emptyList ( ) : Collections . unmodifiableList ( extraBuilds ) ; }
Returns the list of additional futures that should be processed along with this build this future
46
16
140,243
public double getCoverDelta ( GrammarRuleRecord rule ) { // counts which uncovered points shall be covered int new_cover = 0 ; // counts overlaps with previously covered ranges int overlapping_cover = 0 ; // perform the sum computation for ( RuleInterval i : rule . getRuleIntervals ( ) ) { int start = i . getStart ( ) ; int end = i . getEnd ( ) ; for ( int j = start ; j < end ; j ++ ) { if ( range [ j ] ) { overlapping_cover ++ ; } else { new_cover ++ ; } } } // if covers nothing, return 0 if ( 0 == new_cover ) { return 0.0 ; } // if zero overlap, return full weighted cover if ( 0 == overlapping_cover ) { return ( double ) new_cover / ( double ) ( rule . getExpandedRuleString ( ) . length ( ) + rule . getRuleIntervals ( ) . size ( ) ) ; } // else divide newly covered points amount by the sum of the rule string length and occurrence // (i.e. encoding size) return ( ( double ) new_cover / ( double ) ( new_cover + overlapping_cover ) ) / ( double ) ( rule . getExpandedRuleString ( ) . length ( ) + rule . getRuleIntervals ( ) . size ( ) ) ; }
Computes the delta value for the suggested rule candidate .
287
11
140,244
private boolean isCompletelyCoveredBy ( int [ ] isCovered , List < RuleInterval > intervals ) { for ( RuleInterval i : intervals ) { for ( int j = i . getStart ( ) ; j < i . getEnd ( ) ; j ++ ) { if ( isCovered [ j ] == 0 ) { return false ; } } } return true ; }
Checks if the cover is complete .
82
8
140,245
public void expand ( ) { join ( p , r . first ( ) ) ; join ( r . last ( ) , n ) ; // Necessary so that garbage collector // can delete rule and guard. r . theGuard . r = null ; r . theGuard = null ; }
This symbol is the last reference to its rule . The contents of the rule are substituted in its place .
60
21
140,246
public void insert ( String str , int lineno , int colno ) { final String sourceMethod = "insert" ; //$NON-NLS-1$ if ( isTraceLogging ) { log . entering ( JSSource . class . getName ( ) , sourceMethod , new Object [ ] { str , lineno , colno } ) ; } PositionLocator locator = new PositionLocator ( lineno , colno ) ; locator . insert ( str ) ; if ( isTraceLogging ) { log . exiting ( JSSource . class . getName ( ) , sourceMethod , "String \"" + str + "\" inserted at " + mid + "(" + lineno + "," + colno + ")" ) ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } }
Inserts the specified string into the source at the specified location
214
12
140,247
public void appendln ( String str ) { BufferedReader rdr = new BufferedReader ( new StringReader ( str ) ) ; while ( true ) { String line = null ; try { line = rdr . readLine ( ) ; } catch ( IOException e ) { // shouldn't ever happen since we're using a StringReader throw new RuntimeException ( e ) ; } if ( line != null ) { lines . add ( new LineInfo ( line ) ) ; continue ; } break ; } }
Appends the lines in the specified string to the current source .
105
13
140,248
public void disposeAndValidate ( ) throws ObjectNotFoundException , ComposedException { List < NlsObject > errorList = this . duplicateIdErrors ; this . duplicateIdErrors = null ; for ( Resolver resolver : this . id2callableMap . values ( ) ) { if ( ! resolver . resolved ) { errorList . add ( this . bundle . errorObjectNotFound ( resolver . type , resolver . id ) ) ; } } this . id2valueMap = null ; this . id2callableMap = null ; int errorCount = errorList . size ( ) ; if ( errorCount > 0 ) { NlsObject [ ] errors = errorList . toArray ( new NlsObject [ errorCount ] ) ; throw new ComposedException ( errors ) ; } }
This method disposes this context and performs a validation that all IDs have been resolved .
172
17
140,249
public void setNamespace ( String prefix , String uri ) { this . prefix2namespace . put ( prefix , uri ) ; this . namespace2prefix . put ( uri , prefix ) ; }
This method is used to declare a namespace in this context .
44
12
140,250
private ChocoConstraint build ( Constraint cstr ) throws SchedulerException { ChocoMapper mapper = params . getMapper ( ) ; ChocoConstraint cc = mapper . get ( cstr ) ; if ( cc == null ) { throw new SchedulerModelingException ( origin , "No implementation mapped to '" + cstr . getClass ( ) . getSimpleName ( ) + "'" ) ; } return cc ; }
Build a sat constraint
98
4
140,251
private static void checkNodesExistence ( Model mo , Collection < Node > ns ) throws SchedulerModelingException { for ( Node node : ns ) { if ( ! mo . getMapping ( ) . contains ( node ) ) { throw new SchedulerModelingException ( mo , "Unknown node '" + node + "'" ) ; } } }
Check for the existence of nodes in a model
75
9
140,252
public SingleRunnerStatistics getStatistics ( ) { if ( rp != null ) { Measures m = rp . getSolver ( ) . getMeasures ( ) ; stats . setMetrics ( new Metrics ( m ) ) ; stats . setCompleted ( m . getSearchState ( ) . equals ( SearchState . TERMINATED ) || m . getSearchState ( ) . equals ( SearchState . NEW ) ) ; } return stats ; }
Get the statistics about the solving process .
94
8
140,253
protected double calcDistTSAndPattern ( double [ ] ts , double [ ] pValue ) { double INF = 10000000000000000000f ; double bestDist = INF ; int patternLen = pValue . length ; int lastStartP = ts . length - pValue . length + 1 ; if ( lastStartP < 1 ) return bestDist ; Random rand = new Random ( ) ; int startP = rand . nextInt ( ( lastStartP - 1 - 0 ) + 1 ) ; double [ ] slidingWindow = new double [ patternLen ] ; System . arraycopy ( ts , startP , slidingWindow , 0 , patternLen ) ; bestDist = eculideanDistNorm ( pValue , slidingWindow ) ; for ( int i = 0 ; i < lastStartP ; i ++ ) { System . arraycopy ( ts , i , slidingWindow , 0 , patternLen ) ; double tempDist = eculideanDistNormEAbandon ( pValue , slidingWindow , bestDist ) ; if ( tempDist < bestDist ) { bestDist = tempDist ; } } return bestDist ; }
Calculating the distance between time series and pattern .
232
11
140,254
protected double eculideanDistNormEAbandon ( double [ ] ts1 , double [ ] ts2 , double bsfDist ) { double dist = 0 ; double tsLen = ts1 . length ; double bsf = Math . pow ( tsLen * bsfDist , 2 ) ; for ( int i = 0 ; i < ts1 . length ; i ++ ) { double diff = ts1 [ i ] - ts2 [ i ] ; dist += Math . pow ( diff , 2 ) ; if ( dist > bsf ) return Double . NaN ; } return Math . sqrt ( dist ) / tsLen ; }
Normalized early abandoned Euclidean distance .
133
9
140,255
protected double eculideanDistNorm ( double [ ] ts1 , double [ ] ts2 ) { double dist = 0 ; double tsLen = ts1 . length ; for ( int i = 0 ; i < ts1 . length ; i ++ ) { double diff = ts1 [ i ] - ts2 [ i ] ; dist += Math . pow ( diff , 2 ) ; } return Math . sqrt ( dist ) / tsLen ; }
Normalized Euclidean distance .
94
7
140,256
private static void toAbsoluteFreeResources ( TIntIntHashMap changes , int [ ] sortedMoments ) { for ( int i = 1 ; i < sortedMoments . length ; i ++ ) { int t = sortedMoments [ i ] ; int lastT = sortedMoments [ i - 1 ] ; int lastFree = changes . get ( lastT ) ; changes . put ( t , changes . get ( t ) + lastFree ) ; } }
Translation for a relatives resources changes to an absolute free resources .
97
12
140,257
private void addLinkConstraints ( ReconfigurationProblem rp ) { // Links limitation List < Task > tasksListUp = new ArrayList <> ( ) ; List < Task > tasksListDown = new ArrayList <> ( ) ; List < IntVar > heightsListUp = new ArrayList <> ( ) ; List < IntVar > heightsListDown = new ArrayList <> ( ) ; for ( Link l : net . getLinks ( ) ) { for ( VM vm : rp . getVMs ( ) ) { VMTransition a = rp . getVMAction ( vm ) ; if ( a instanceof RelocatableVM && ! a . getDSlice ( ) . getHoster ( ) . isInstantiatedTo ( a . getCSlice ( ) . getHoster ( ) . getValue ( ) ) ) { Node src = source . getMapping ( ) . getVMLocation ( vm ) ; Node dst = rp . getNode ( a . getDSlice ( ) . getHoster ( ) . getValue ( ) ) ; List < Link > path = net . getRouting ( ) . getPath ( src , dst ) ; // Check first if the link is on migration path if ( path . contains ( l ) ) { // Get link direction LinkDirection linkDirection = net . getRouting ( ) . getLinkDirection ( src , dst , l ) ; // UpLink if ( linkDirection == LinkDirection . UPLINK ) { tasksListUp . add ( ( ( RelocatableVM ) a ) . getMigrationTask ( ) ) ; heightsListUp . add ( ( ( RelocatableVM ) a ) . getBandwidth ( ) ) ; } // DownLink else { tasksListDown . add ( ( ( RelocatableVM ) a ) . getMigrationTask ( ) ) ; heightsListDown . add ( ( ( RelocatableVM ) a ) . getBandwidth ( ) ) ; } } } } if ( ! tasksListUp . isEmpty ( ) ) { // Post the cumulative constraint for the current UpLink csp . post ( csp . cumulative ( tasksListUp . toArray ( new Task [ tasksListUp . size ( ) ] ) , heightsListUp . toArray ( new IntVar [ heightsListUp . size ( ) ] ) , csp . intVar ( l . getCapacity ( ) ) , true ) ) ; tasksListUp . clear ( ) ; heightsListUp . clear ( ) ; } if ( ! tasksListDown . isEmpty ( ) ) { // Post the cumulative constraint for the current DownLink csp . post ( csp . cumulative ( tasksListDown . toArray ( new Task [ tasksListDown . size ( ) ] ) , heightsListDown . toArray ( new IntVar [ heightsListDown . size ( ) ] ) , csp . intVar ( l . getCapacity ( ) ) , true ) ) ; tasksListDown . clear ( ) ; heightsListDown . clear ( ) ; } } }
Add the cumulative constraints for each link .
648
8
140,258
public static void fill ( Mapping src , Mapping dst ) { for ( Node off : src . getOfflineNodes ( ) ) { dst . addOfflineNode ( off ) ; } for ( VM r : src . getReadyVMs ( ) ) { dst . addReadyVM ( r ) ; } for ( Node on : src . getOnlineNodes ( ) ) { dst . addOnlineNode ( on ) ; for ( VM r : src . getRunningVMs ( on ) ) { dst . addRunningVM ( r , on ) ; } for ( VM s : src . getSleepingVMs ( on ) ) { dst . addSleepingVM ( s , on ) ; } } }
Fill a destination mapping with all the elements in a source mapping
150
12
140,259
public String toRuleString ( ) { if ( 0 == this . ruleNumber ) { return this . grammar . r0String ; } return this . first . toString ( ) + SPACE + this . second . toString ( ) + SPACE ; }
Return the prefixed with R rule .
52
8
140,260
public int [ ] getOccurrences ( ) { int [ ] res = new int [ this . occurrences . size ( ) ] ; for ( int i = 0 ; i < this . occurrences . size ( ) ; i ++ ) { res [ i ] = this . occurrences . get ( i ) ; } return res ; }
Gets occurrences .
68
4
140,261
static public boolean isProvisional ( Iterable < ICacheKeyGenerator > keyGens ) { boolean provisional = false ; for ( ICacheKeyGenerator keyGen : keyGens ) { if ( keyGen . isProvisional ( ) ) { provisional = true ; break ; } } return provisional ; }
Return true if any of the cache key generators in the array is a provisional cache key generator .
67
19
140,262
public static < E > Collection < E > unionColl ( Collection < E > c1 , Collection < E > c2 ) { return new UColl < E > ( c1 , c2 ) ; }
Returns the immutable union of two collections .
43
8
140,263
protected void unfoldModulesHelper ( Object obj , String path , String [ ] aPrefixes , Map < Integer , String > modules ) throws IOException , JSONException { final String sourceMethod = "unfoldModulesHelper" ; //$NON-NLS-1$ if ( isTraceLogging ) { log . entering ( RequestedModuleNames . class . getName ( ) , sourceMethod , new Object [ ] { obj , path , aPrefixes != null ? Arrays . asList ( aPrefixes ) : null , modules } ) ; } if ( obj instanceof JSONObject ) { JSONObject jsonobj = ( JSONObject ) obj ; Iterator < ? > it = jsonobj . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { String key = ( String ) it . next ( ) ; String newpath = path + "/" + key ; //$NON-NLS-1$ unfoldModulesHelper ( jsonobj . get ( key ) , newpath , aPrefixes , modules ) ; } } else if ( obj instanceof String ) { String [ ] values = ( ( String ) obj ) . split ( "-" ) ; //$NON-NLS-1$ int idx = Integer . parseInt ( values [ 0 ] ) ; if ( modules . get ( idx ) != null ) { throw new BadRequestException ( ) ; } modules . put ( idx , values . length > 1 ? ( ( aPrefixes != null ? aPrefixes [ Integer . parseInt ( values [ 1 ] ) ] : values [ 1 ] ) + "!" + path ) : //$NON-NLS-1$ path ) ; } else { throw new BadRequestException ( ) ; } if ( isTraceLogging ) { log . exiting ( RequestedModuleNames . class . getName ( ) , sourceMethod , modules ) ; } }
Helper routine to unfold folded module names
413
7
140,264
public static < K , V > MapFactory < K , V > cow ( MapFactory < K , V > underMapFact ) { throw new UnsupportedOperationException ( "Not implemented yet" ) ; }
Copy - on - write maps . UNIMPLEMENTED YET .
43
15
140,265
private void sealObject ( ScriptableObject obj ) { obj . sealObject ( ) ; Object [ ] ids = obj . getIds ( ) ; for ( Object id : ids ) { Object child = obj . get ( id ) ; if ( child instanceof ScriptableObject ) { sealObject ( ( ScriptableObject ) child ) ; } } }
Recursively seals the specified object and all the objects it contains .
75
14
140,266
protected String _resolve ( String name , Features features , Set < String > dependentFeatures , boolean resolveAliases , boolean evaluateHasPluginConditionals , int recursionCount , StringBuffer sb ) { final String sourceMethod = "_resolve" ; //$NON-NLS-1$ boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( ConfigImpl . class . getName ( ) , sourceMethod , new Object [ ] { name , features , dependentFeatures , resolveAliases , evaluateHasPluginConditionals , recursionCount , sb } ) ; } String result = name ; if ( name != null && name . length ( ) != 0 ) { if ( recursionCount >= MAX_RECURSION_COUNT ) { throw new IllegalStateException ( "Excessive recursion in resolver: " + name ) ; //$NON-NLS-1$ } int idx = name . indexOf ( "!" ) ; //$NON-NLS-1$ if ( idx != - 1 && HAS_PATTERN . matcher ( name . substring ( 0 , idx ) ) . find ( ) ) { result = resolveHasPlugin ( name . substring ( idx + 1 ) , features , dependentFeatures , resolveAliases , evaluateHasPluginConditionals , recursionCount + 1 , sb ) ; result = result . contains ( "?" ) ? ( name . substring ( 0 , idx + 1 ) + result ) : result ; //$NON-NLS-1$ } else if ( resolveAliases && getAliases ( ) != null ) { if ( idx != - 1 ) { // non-has plugin // If the module id specifies a plugin, then process each part individually Matcher m = plugins2 . matcher ( name ) ; StringBuffer sbResult = new StringBuffer ( ) ; while ( m . find ( ) ) { String replacement = _resolve ( m . group ( 0 ) , features , dependentFeatures , true , evaluateHasPluginConditionals , recursionCount + 1 , sb ) ; m . appendReplacement ( sbResult , replacement ) ; } m . appendTail ( sbResult ) ; result = sbResult . toString ( ) ; } String candidate = resolveAliases ( name , features , dependentFeatures , sb ) ; if ( candidate != null && candidate . length ( ) > 0 && ! candidate . equals ( name ) ) { if ( sb != null ) { sb . append ( ", " ) . append ( MessageFormat . format ( //$NON-NLS-1$ Messages . ConfigImpl_6 , new Object [ ] { name + " --> " + candidate } //$NON-NLS-1$ ) ) ; } result = _resolve ( candidate , features , dependentFeatures , true , evaluateHasPluginConditionals , recursionCount + 1 , sb ) ; } } } if ( isTraceLogging ) { log . exiting ( ConfigImpl . class . getName ( ) , sourceMethod , result ) ; } return result ; }
Resolves a module id by applying alias resolution and has! loader plugin resolution .
676
16
140,267
protected URI loadConfigUri ( ) throws URISyntaxException , FileNotFoundException { Collection < String > configNames = getAggregator ( ) . getInitParams ( ) . getValues ( InitParams . CONFIG_INITPARAM ) ; if ( configNames . size ( ) != 1 ) { throw new IllegalArgumentException ( InitParams . CONFIG_INITPARAM ) ; } String configName = configNames . iterator ( ) . next ( ) ; return new URI ( configName ) ; }
Initializes and returns the URI to the server - side config JavaScript
112
13
140,268
protected Location loadBaseURI ( Scriptable cfg ) throws URISyntaxException { Object baseObj = cfg . get ( BASEURL_CONFIGPARAM , cfg ) ; Location result ; if ( baseObj == Scriptable . NOT_FOUND ) { result = new Location ( getConfigUri ( ) . resolve ( "." ) ) ; //$NON-NLS-1$ } else { Location loc = loadLocation ( baseObj , true ) ; Location configLoc = new Location ( getConfigUri ( ) , loc . getOverride ( ) != null ? getConfigUri ( ) : null ) ; result = configLoc . resolve ( loc ) ; } return result ; }
Initializes and returns the base URI specified by the baseUrl property in the server - side config JavaScript
148
20
140,269
protected Scriptable loadConfig ( String configScript ) throws IOException { configScript = processConfig ( configScript ) ; Context cx = Context . enter ( ) ; Scriptable config ; try { sharedScope = cx . initStandardObjects ( null , true ) ; // set up options object IOptions options = aggregator . getOptions ( ) ; if ( options != null ) { optionsUpdated ( options , 1 ) ; } // set up init params object InitParams initParams = aggregator . getInitParams ( ) ; if ( initParams != null ) { Scriptable jsInitParams = cx . newObject ( sharedScope ) ; Collection < String > names = initParams . getNames ( ) ; for ( String name : names ) { Collection < String > values = initParams . getValues ( name ) ; Object value = Context . javaToJS ( values . toArray ( new String [ values . size ( ) ] ) , sharedScope ) ; ScriptableObject . putProperty ( jsInitParams , name , value ) ; } ScriptableObject . putProperty ( sharedScope , "initParams" , jsInitParams ) ; //$NON-NLS-1$ } // set up bundle manifest headers property if ( aggregator . getPlatformServices ( ) != null ) { if ( aggregator . getPlatformServices ( ) . getHeaders ( ) != null ) { Dictionary < String , String > headers = ( Dictionary < String , String > ) ( aggregator . getPlatformServices ( ) . getHeaders ( ) ) ; Scriptable jsHeaders = cx . newObject ( sharedScope ) ; Enumeration < String > keys = headers . keys ( ) ; while ( keys . hasMoreElements ( ) ) { String key = keys . nextElement ( ) ; Object value = Context . javaToJS ( headers . get ( key ) , sharedScope ) ; ScriptableObject . putProperty ( jsHeaders , key , value ) ; } ScriptableObject . putProperty ( sharedScope , "headers" , jsHeaders ) ; //$NON-NLS-1$ } } // set up console object Console console = newConsole ( ) ; Object jsConsole = Context . javaToJS ( console , sharedScope ) ; ScriptableObject . putProperty ( sharedScope , "console" , jsConsole ) ; //$NON-NLS-1$ GetPropertyFunction getPropertyFn = newGetPropertyFunction ( sharedScope , aggregator ) ; ScriptableObject . putProperty ( sharedScope , "getProperty" , getPropertyFn ) ; //$NON-NLS-1$ // Call the registered scope modifiers callConfigScopeModifiers ( sharedScope ) ; cx . evaluateString ( sharedScope , "var config = " + //$NON-NLS-1$ aggregator . substituteProps ( configScript , new IAggregator . SubstitutionTransformer ( ) { @ Override public String transform ( String name , String value ) { // escape forward slashes for javascript literals return value . replace ( "\\" , "\\\\" ) ; //$NON-NLS-1$ //$NON-NLS-2$ } } ) , getConfigUri ( ) . toString ( ) , 1 , null ) ; config = ( Scriptable ) sharedScope . get ( "config" , sharedScope ) ; //$NON-NLS-1$ if ( config == Scriptable . NOT_FOUND ) { throw new IllegalStateException ( "config is not defined." ) ; //$NON-NLS-1$ } } finally { Context . exit ( ) ; } return config ; }
Loads the config JavaScript and returns the parsed config in a Map
777
13
140,270
protected Map < String , IPackage > loadPackages ( Scriptable cfg ) throws URISyntaxException { Object obj = cfg . get ( PACKAGES_CONFIGPARAM , cfg ) ; Map < String , IPackage > packages = new HashMap < String , IPackage > ( ) ; if ( obj instanceof Scriptable ) { for ( Object id : ( ( Scriptable ) obj ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object pkg = ( ( Scriptable ) obj ) . get ( ( Integer ) i , ( Scriptable ) obj ) ; IPackage p = newPackage ( pkg ) ; if ( ! packages . containsKey ( p . getName ( ) ) ) { packages . put ( p . getName ( ) , p ) ; } } } } return packages ; }
Initializes and returns the map of packages based on the information in the server - side config JavaScript
190
19
140,271
protected Map < String , Location > loadPaths ( Scriptable cfg ) throws URISyntaxException { Object pathlocs = cfg . get ( PATHS_CONFIGPARAM , cfg ) ; Map < String , Location > paths = new HashMap < String , Location > ( ) ; if ( pathlocs instanceof Scriptable ) { for ( Object key : ( ( Scriptable ) pathlocs ) . getIds ( ) ) { String name = toString ( key ) ; if ( ! paths . containsKey ( name ) && key instanceof String ) { Location location = loadLocation ( ( ( Scriptable ) pathlocs ) . get ( name , ( Scriptable ) pathlocs ) , false ) ; paths . put ( name , getBase ( ) . resolve ( location ) ) ; } } } return paths ; }
Initializes and returns the map of paths based on the information in the server - side config JavaScript
179
19
140,272
protected List < IAlias > loadAliases ( Scriptable cfg ) throws IOException { Object aliasList = cfg . get ( ALIASES_CONFIGPARAM , cfg ) ; List < IAlias > aliases = new LinkedList < IAlias > ( ) ; if ( aliasList instanceof Scriptable ) { for ( Object id : ( ( Scriptable ) aliasList ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object entry = ( ( Scriptable ) aliasList ) . get ( ( Integer ) i , ( Scriptable ) aliasList ) ; if ( entry instanceof Scriptable ) { Scriptable vec = ( Scriptable ) entry ; Object pattern = vec . get ( 0 , vec ) ; Object replacement = vec . get ( 1 , vec ) ; if ( pattern == Scriptable . NOT_FOUND || replacement == Scriptable . NOT_FOUND ) { throw new IllegalArgumentException ( toString ( entry ) ) ; } if ( pattern instanceof Scriptable && "RegExp" . equals ( ( ( Scriptable ) pattern ) . getClassName ( ) ) ) { //$NON-NLS-1$ String regexlit = toString ( pattern ) ; String regex = regexlit . substring ( 1 , regexlit . lastIndexOf ( "/" ) ) ; //$NON-NLS-1$ String flags = regexlit . substring ( regexlit . lastIndexOf ( "/" ) + 1 ) ; //$NON-NLS-1$ int options = 0 ; if ( flags . contains ( "i" ) ) { //$NON-NLS-1$ options |= Pattern . CASE_INSENSITIVE ; } pattern = Pattern . compile ( regex , options ) ; } else { pattern = toString ( pattern ) ; } if ( ! ( replacement instanceof Scriptable ) || ! "Function" . equals ( ( ( Scriptable ) replacement ) . getClassName ( ) ) ) { //$NON-NLS-1$ replacement = toString ( replacement ) ; } aliases . add ( newAlias ( pattern , replacement ) ) ; } else { throw new IllegalArgumentException ( Context . toString ( ALIASES_CONFIGPARAM + "[" + i + "] = " + Context . toString ( entry ) ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } } else { throw new IllegalArgumentException ( "Unrecognized type for " + ALIASES_CONFIGPARAM + " - " + aliasList . getClass ( ) . toString ( ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } } } return aliases ; }
Initializes and returns the list of aliases defined in the server - side config JavaScript
597
16
140,273
protected List < String > loadDeps ( Scriptable cfg ) { final String methodName = "loadDeps" ; //$NON-NLS-1$ Object depsList = cfg . get ( DEPS_CONFIGPARAM , cfg ) ; List < String > deps = new LinkedList < String > ( ) ; if ( depsList instanceof Scriptable ) { for ( Object id : ( ( Scriptable ) depsList ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object entry = ( ( Scriptable ) depsList ) . get ( ( Integer ) i , ( Scriptable ) depsList ) ; deps . add ( toString ( entry ) ) ; } } log . logp ( Level . WARNING , ConfigImpl . class . getName ( ) , methodName , Messages . ConfigImpl_0 ) ; } return deps ; }
Initializes and returns the list of module dependencies specified in the server - side config JavaScript .
203
18
140,274
protected int loadExpires ( Scriptable cfg ) { int expires = 0 ; Object oExpires = cfg . get ( EXPIRES_CONFIGPARAM , cfg ) ; if ( oExpires != Scriptable . NOT_FOUND ) { try { expires = Integer . parseInt ( toString ( oExpires ) ) ; } catch ( NumberFormatException ignore ) { throw new IllegalArgumentException ( EXPIRES_CONFIGPARAM + "=" + oExpires ) ; //$NON-NLS-1$ } } return expires ; }
Initializes and returns the expires time from the server - side config JavaScript
122
14
140,275
protected boolean loadDepsIncludeBaseUrl ( Scriptable cfg ) { boolean result = false ; Object value = cfg . get ( DEPSINCLUDEBASEURL_CONFIGPARAM , cfg ) ; if ( value != Scriptable . NOT_FOUND ) { result = TypeUtil . asBoolean ( toString ( value ) , false ) ; } return result ; }
Initializes and returns the flag indicating if files and directories located under the base directory should be scanned for javascript files when building the module dependency mappings . The default is false .
85
35
140,276
protected boolean loadCoerceUndefinedToFalse ( Scriptable cfg ) { boolean result = false ; Object value = cfg . get ( COERCEUNDEFINEDTOFALSE_CONFIGPARAM , cfg ) ; if ( value != Scriptable . NOT_FOUND ) { result = TypeUtil . asBoolean ( toString ( value ) , false ) ; } return result ; }
Initializes and returns the flag indicating if features not specified in the feature set from the request should be treated as false when evaluating has conditionals in javascript code . The default is false .
87
37
140,277
protected Set < String > loadPluginDelegators ( Scriptable cfg , String name ) { Set < String > result = null ; Object delegators = cfg . get ( name , cfg ) ; if ( delegators != Scriptable . NOT_FOUND && delegators instanceof Scriptable ) { result = new HashSet < String > ( ) ; for ( Object id : ( ( Scriptable ) delegators ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object entry = ( ( Scriptable ) delegators ) . get ( ( Integer ) i , ( Scriptable ) delegators ) ; result . add ( entry . toString ( ) ) ; } } result = Collections . unmodifiableSet ( result ) ; } else { result = Collections . emptySet ( ) ; } return result ; }
Common routine to load text or js plugin delegators
182
10
140,278
protected void callConfigModifiers ( Scriptable rawConfig ) { if ( aggregator . getPlatformServices ( ) != null ) { IServiceReference [ ] refs = null ; try { refs = aggregator . getPlatformServices ( ) . getServiceReferences ( IConfigModifier . class . getName ( ) , "(name=" + getAggregator ( ) . getName ( ) + ")" ) ; //$NON-NLS-1$ //$NON-NLS-2$ } catch ( PlatformServicesException e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } if ( refs != null ) { for ( IServiceReference ref : refs ) { IConfigModifier modifier = ( IConfigModifier ) aggregator . getPlatformServices ( ) . getService ( ref ) ; if ( modifier != null ) { try { modifier . modifyConfig ( getAggregator ( ) , rawConfig ) ; } catch ( Exception e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } finally { aggregator . getPlatformServices ( ) . ungetService ( ref ) ; } } } } } }
Calls the registered config modifiers to give them an opportunity to modify the raw config before config properties are evaluated .
298
22
140,279
protected void callConfigScopeModifiers ( Scriptable scope ) { if ( aggregator . getPlatformServices ( ) != null ) { IServiceReference [ ] refs = null ; try { refs = aggregator . getPlatformServices ( ) . getServiceReferences ( IConfigScopeModifier . class . getName ( ) , "(name=" + getAggregator ( ) . getName ( ) + ")" ) ; //$NON-NLS-1$ //$NON-NLS-2$ } catch ( PlatformServicesException e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } if ( refs != null ) { for ( IServiceReference ref : refs ) { IConfigScopeModifier adaptor = ( IConfigScopeModifier ) aggregator . getPlatformServices ( ) . getService ( ref ) ; if ( adaptor != null ) { try { adaptor . modifyScope ( getAggregator ( ) , scope ) ; } catch ( Exception e ) { if ( log . isLoggable ( Level . SEVERE ) ) { log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } } finally { aggregator . getPlatformServices ( ) . ungetService ( ref ) ; } } } } } }
Calls the registered config scope modifiers to give them an opportunity to prepare the scope object prior to evaluating the config JavaScript
303
23
140,280
protected boolean isValidType ( Class < ? > type , Annotation [ ] classAnnotations ) { if ( type == null ) return false ; if ( annotated ) { return checkAnnotation ( type ) ; } else if ( scanpackages != null ) { String classPackage = type . getPackage ( ) . getName ( ) ; for ( String pkg : scanpackages ) { if ( classPackage . startsWith ( pkg ) ) { if ( annotated ) { return checkAnnotation ( type ) ; } else return true ; } } return false ; } else if ( clazzes != null ) { for ( Class < ? > cls : clazzes ) { // must strictly equal. Don't check // inheritance if ( cls == type ) return true ; } return false ; } return true ; }
Check whether a class can be serialized or deserialized . It can check based on packages annotations on entities or explicit classes .
171
26
140,281
public void writeTo ( Object t , Class < ? > type , Type genericType , Annotation [ ] annotations , MediaType mediaType , MultivaluedMap < String , Object > httpHeaders , OutputStream entityStream ) throws IOException , WebApplicationException { SerializeFilter filter = null ; if ( pretty ) { if ( fastJsonConfig . serializerFeatures == null ) fastJsonConfig . serializerFeatures = new SerializerFeature [ ] { SerializerFeature . PrettyFormat } ; else { List < SerializerFeature > serializerFeatures = Arrays . asList ( fastJsonConfig . serializerFeatures ) ; serializerFeatures . add ( SerializerFeature . PrettyFormat ) ; fastJsonConfig . serializerFeatures = serializerFeatures . toArray ( new SerializerFeature [ ] { } ) ; } } if ( fastJsonConfig . serializeFilters != null ) filter = fastJsonConfig . serializeFilters . get ( type ) ; String jsonStr = toJSONString ( t , filter , fastJsonConfig . serializerFeatures ) ; if ( jsonStr != null ) entityStream . write ( jsonStr . getBytes ( ) ) ; }
Method that JAX - RS container calls to serialize given value .
249
14
140,282
public Object readFrom ( Class < Object > type , Type genericType , Annotation [ ] annotations , MediaType mediaType , MultivaluedMap < String , String > httpHeaders , InputStream entityStream ) throws IOException , WebApplicationException { String input = null ; try { input = IOUtils . inputStreamToString ( entityStream ) ; } catch ( Exception e ) { } if ( input == null ) { return null ; } if ( fastJsonConfig . features == null ) return JSON . parseObject ( input , type , fastJsonConfig . parserConfig , JSON . DEFAULT_PARSER_FEATURE ) ; else return JSON . parseObject ( input , type , fastJsonConfig . parserConfig , JSON . DEFAULT_PARSER_FEATURE , fastJsonConfig . features ) ; }
Method that JAX - RS container calls to deserialize given value .
174
15
140,283
public static ArrayList < SameLengthMotifs > performPruning ( double [ ] ts , GrammarRules grammarRules , double thresholdLength , double thresholdCom , double fractionTopDist ) { RuleOrganizer ro = new RuleOrganizer ( ) ; ArrayList < SameLengthMotifs > allClassifiedMotifs = ro . classifyMotifs ( thresholdLength , grammarRules ) ; allClassifiedMotifs = ro . removeOverlappingInSimiliar ( allClassifiedMotifs , grammarRules , ts , thresholdCom ) ; ArrayList < SameLengthMotifs > newAllClassifiedMotifs = ro . refinePatternsByClustering ( grammarRules , ts , allClassifiedMotifs , fractionTopDist ) ; return newAllClassifiedMotifs ; }
Performs clustering .
170
5
140,284
public static ArrayList < PackedRuleRecord > getPackedRule ( ArrayList < SameLengthMotifs > newAllClassifiedMotifs ) { ArrayList < PackedRuleRecord > arrPackedRuleRecords = new ArrayList < PackedRuleRecord > ( ) ; int i = 0 ; for ( SameLengthMotifs subsequencesInClass : newAllClassifiedMotifs ) { int classIndex = i ; int subsequencesNumber = subsequencesInClass . getSameLenMotifs ( ) . size ( ) ; int minLength = subsequencesInClass . getMinMotifLen ( ) ; int maxLength = subsequencesInClass . getMaxMotifLen ( ) ; PackedRuleRecord packedRuleRecord = new PackedRuleRecord ( ) ; packedRuleRecord . setClassIndex ( classIndex ) ; packedRuleRecord . setSubsequenceNumber ( subsequencesNumber ) ; packedRuleRecord . setMinLength ( minLength ) ; packedRuleRecord . setMaxLength ( maxLength ) ; arrPackedRuleRecords . add ( packedRuleRecord ) ; i ++ ; } return arrPackedRuleRecords ; }
Gets packed rules set .
242
6
140,285
protected Dictionary < ? , ? > getBundleHeaders ( String bundleName ) throws NotFoundException { final String sourceMethod = "getBundleHeaders" ; //$NON-NLS-1$ boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( BundleVersionsHashBase . class . getName ( ) , sourceMethod , new Object [ ] { bundleName } ) ; } Bundle result = "." . equals ( bundleName ) ? contributingBundle : bundleResolver . getBundle ( bundleName ) ; //$NON-NLS-1$ if ( result == null ) { throw new NotFoundException ( "Bundle " + bundleName + " not found." ) ; //$NON-NLS-1$ //$NON-NLS-2$ } if ( isTraceLogging ) { log . exiting ( BundleVersionsHashBase . class . getName ( ) , sourceMethod , result . getHeaders ( ) ) ; } return result . getHeaders ( ) ; }
Returns the bundle headers for the specified bundle .
238
9
140,286
public boolean checkConformance ( BtrPlaceTree t , List < BtrpOperand > ops ) { //Arity error if ( ops . size ( ) != getParameters ( ) . length ) { t . ignoreError ( "'" + pretty ( ops ) + "' cannot be casted to '" + getSignature ( ) + "'" ) ; return false ; } //Type checking for ( int i = 0 ; i < ops . size ( ) ; i ++ ) { BtrpOperand o = ops . get ( i ) ; ConstraintParam < ? > p = params [ i ] ; if ( o == IgnorableOperand . getInstance ( ) ) { return false ; } if ( ! p . isCompatibleWith ( t , o ) ) { t . ignoreError ( "'" + pretty ( ops ) + "' cannot be casted to '" + getSignature ( ) + "'" ) ; return false ; } } return true ; }
Check if the provided parameters match the constraint signature
205
9
140,287
public Script build ( File f ) throws ScriptBuilderException { int k = f . getAbsolutePath ( ) . hashCode ( ) ; if ( dates . containsKey ( k ) && dates . get ( k ) == f . lastModified ( ) && cache . containsKey ( f . getPath ( ) ) ) { LOGGER . debug ( "get '" + f . getName ( ) + "' from the cache" ) ; return cache . get ( f . getPath ( ) ) ; } LOGGER . debug ( f . getName ( ) + " is built from the file" ) ; dates . put ( k , f . lastModified ( ) ) ; String name = f . getName ( ) ; try { Script v = build ( new ANTLRFileStream ( f . getAbsolutePath ( ) ) ) ; if ( ! name . equals ( v . getlocalName ( ) + Script . EXTENSION ) ) { throw new ScriptBuilderException ( "Script '" + v . getlocalName ( ) + "' must be declared in a file named '" + v . getlocalName ( ) + Script . EXTENSION ) ; } cache . put ( f . getPath ( ) , v ) ; return v ; } catch ( IOException e ) { throw new ScriptBuilderException ( e . getMessage ( ) , e ) ; } }
Build a script from a file .
289
7
140,288
@ SuppressWarnings ( "squid:S1166" ) //For the UnsupportedOperationException private Script build ( CharStream cs ) throws ScriptBuilderException { Script v = new Script ( ) ; ANTLRBtrplaceSL2Lexer lexer = new ANTLRBtrplaceSL2Lexer ( cs ) ; ErrorReporter errorReporter = errBuilder . build ( v ) ; lexer . setErrorReporter ( errorReporter ) ; CommonTokenStream tokens = new CommonTokenStream ( lexer ) ; ANTLRBtrplaceSL2Parser parser = new ANTLRBtrplaceSL2Parser ( tokens ) ; parser . setErrorReporter ( errorReporter ) ; SymbolsTable t = new SymbolsTable ( ) ; parser . setTreeAdaptor ( new BtrPlaceTreeAdaptor ( v , model , namingServiceNodes , namingServiceVMs , tpls , errorReporter , t , includes , catalog ) ) ; try { BtrPlaceTree tree = ( BtrPlaceTree ) parser . script_decl ( ) . getTree ( ) ; if ( tree != null ) { if ( tree . token != null ) { tree . go ( tree ) ; //Single instruction } else { for ( int i = 0 ; i < tree . getChildCount ( ) ; i ++ ) { tree . getChild ( i ) . go ( tree ) ; } } } } catch ( RecognitionException e ) { throw new ScriptBuilderException ( e . getMessage ( ) , e ) ; } catch ( UnsupportedOperationException e ) { //We only keep the error message errorReporter . append ( 0 , 0 , e . getMessage ( ) ) ; } if ( ! errorReporter . getErrors ( ) . isEmpty ( ) ) { throw new ScriptBuilderException ( errorReporter ) ; } return v ; }
Internal method to check a script from a stream .
393
10
140,289
public Graph generateRandomMMapGraph ( String graphName , int size , float dens ) { Graph graph = null ; String dir = "graphs/MMap/" + graphName ; SerializationUtils . deleteMMapGraph ( dir ) ; graph = new Graph ( new MMapGraphStructure ( dir ) ) ; Random rand = new Random ( ) ; for ( int i = 0 ; i < size ; i ++ ) graph . addNode ( new Node ( i ) ) ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = i + 1 ; j < size ; j ++ ) { if ( rand . nextFloat ( ) < dens ) { int randomCost = Math . abs ( rand . nextInt ( 50 ) ) + 1 ; Edge e = new Edge ( i , j , randomCost ) ; e . setBidirectional ( rand . nextBoolean ( ) ) ; graph . addEdge ( e ) ; } } } return graph ; }
Create a new Graph which has the given graphName size and dens .
210
14
140,290
public static Map < IntVar , VM > makePlacementMap ( ReconfigurationProblem rp ) { Map < IntVar , VM > m = new HashMap <> ( rp . getFutureRunningVMs ( ) . size ( ) ) ; for ( VM vm : rp . getFutureRunningVMs ( ) ) { IntVar v = rp . getVMAction ( vm ) . getDSlice ( ) . getHoster ( ) ; m . put ( v , vm ) ; } return m ; }
Map a map where keys are the placement variable of the future - running VMs and values are the VM identifier .
112
23
140,291
public final void validate ( StringBuilder source ) { int length = source . length ( ) ; source . append ( ' ' ) ; source . append ( getSourceIdentifier ( ) ) ; doValidate ( source ) ; // reset source for recursive invocation... source . setLength ( length ) ; }
This method validates this segment recursively to ensure the correctness of the configured format .
62
18
140,292
public ShareableResource setConsumption ( VM vm , int val ) { if ( val < 0 ) { throw new IllegalArgumentException ( String . format ( "The '%s' consumption of VM '%s' must be >= 0" , rcId , vm ) ) ; } vmsConsumption . put ( vm , val ) ; return this ; }
Set the resource consumption of a VM .
76
8
140,293
public ShareableResource setConsumption ( int val , VM ... vms ) { Stream . of ( vms ) . forEach ( v -> setConsumption ( v , val ) ) ; return this ; }
Set the resource consumption of VMs .
44
8
140,294
public ShareableResource setCapacity ( Node n , int val ) { if ( val < 0 ) { throw new IllegalArgumentException ( String . format ( "The '%s' capacity of node '%s' must be >= 0" , rcId , n ) ) ; } nodesCapacity . put ( n , val ) ; return this ; }
Set the resource consumption of a node .
75
8
140,295
public ShareableResource setCapacity ( int val , Node ... nodes ) { Stream . of ( nodes ) . forEach ( n -> this . setCapacity ( n , val ) ) ; return this ; }
Set the resource consumption of nodes .
44
7
140,296
public int sumConsumptions ( Collection < VM > ids , boolean undef ) { int s = 0 ; for ( VM u : ids ) { if ( consumptionDefined ( u ) || undef ) { s += vmsConsumption . get ( u ) ; } } return s ; }
Get the cumulative VMs consumption .
64
7
140,297
public int sumCapacities ( Collection < Node > ids , boolean undef ) { int s = 0 ; for ( Node u : ids ) { if ( capacityDefined ( u ) || undef ) { s += nodesCapacity . get ( u ) ; } } return s ; }
Get the cumulative nodes capacity .
63
6
140,298
public static ShareableResource get ( Model mo , String id ) { return ( ShareableResource ) mo . getView ( VIEW_ID_BASE + id ) ; }
Get the view associated to a model if exists
36
9
140,299
public String getlocalName ( ) { if ( fqn . contains ( "." ) ) { return this . fqn . substring ( fqn . lastIndexOf ( ' ' ) + 1 , this . fqn . length ( ) ) ; } return fqn ; }
Get the local name of the script .
63
8