@@ -138,74 +138,6 @@ public void run() {
138
138
}));
139
139
}
140
140
141
- public List <JobInstance > listAllJobs (final String cubeName , final String projectName , final List <JobStatusEnum > statusList , final Integer limitValue , final Integer offsetValue , final JobTimeFilterEnum timeFilter ) throws IOException , JobException {
142
- Integer limit = (null == limitValue ) ? 30 : limitValue ;
143
- Integer offset = (null == offsetValue ) ? 0 : offsetValue ;
144
- List <JobInstance > jobs = listAllJobs (cubeName , projectName , statusList , timeFilter );
145
- Collections .sort (jobs );
146
-
147
- if (jobs .size () <= offset ) {
148
- return Collections .emptyList ();
149
- }
150
-
151
- if ((jobs .size () - offset ) < limit ) {
152
- return jobs .subList (offset , jobs .size ());
153
- }
154
-
155
- return jobs .subList (offset , offset + limit );
156
- }
157
-
158
- public List <JobInstance > listAllJobs (final String cubeName , final String projectName , final List <JobStatusEnum > statusList , final JobTimeFilterEnum timeFilter ) {
159
- Calendar calendar = Calendar .getInstance ();
160
- calendar .setTime (new Date ());
161
- long timeStartInMillis = getTimeStartInMillis (calendar , timeFilter );
162
- return listCubeJobInstance (cubeName , projectName , statusList , timeStartInMillis , Long .MAX_VALUE );
163
- }
164
-
165
- @ Deprecated
166
- public List <JobInstance > listAllJobs (final String cubeName , final String projectName , final List <JobStatusEnum > statusList , final Integer limitValue , final Integer offsetValue ) throws IOException , JobException {
167
- Integer limit = (null == limitValue ) ? 30 : limitValue ;
168
- Integer offset = (null == offsetValue ) ? 0 : offsetValue ;
169
- List <JobInstance > jobs = listAllJobs (cubeName , projectName , statusList );
170
- Collections .sort (jobs );
171
-
172
- if (jobs .size () <= offset ) {
173
- return Collections .emptyList ();
174
- }
175
-
176
- if ((jobs .size () - offset ) < limit ) {
177
- return jobs .subList (offset , jobs .size ());
178
- }
179
-
180
- return jobs .subList (offset , offset + limit );
181
- }
182
-
183
- public List <JobInstance > listAllJobs (final String cubeName , final String projectName , final List <JobStatusEnum > statusList ) {
184
- return listCubeJobInstance (cubeName , projectName , statusList );
185
- }
186
-
187
- private List <JobInstance > listCubeJobInstance (final String cubeName , final String projectName , List <JobStatusEnum > statusList , final long timeStartInMillis , final long timeEndInMillis ) {
188
- Set <ExecutableState > states = convertStatusEnumToStates (statusList );
189
- final Map <String , Output > allOutputs = getExecutableManager ().getAllOutputs (timeStartInMillis , timeEndInMillis );
190
- return Lists .newArrayList (FluentIterable .from (listAllCubingJobs (cubeName , projectName , states , timeStartInMillis , timeEndInMillis , allOutputs , false )).transform (new Function <CubingJob , JobInstance >() {
191
- @ Override
192
- public JobInstance apply (CubingJob cubingJob ) {
193
- return parseToJobInstance (cubingJob , allOutputs );
194
- }
195
- }));
196
- }
197
-
198
- private List <JobInstance > listCubeJobInstance (final String cubeName , final String projectName , List <JobStatusEnum > statusList ) {
199
- Set <ExecutableState > states = convertStatusEnumToStates (statusList );
200
- final Map <String , Output > allOutputs = getExecutableManager ().getAllOutputs ();
201
- return Lists .newArrayList (FluentIterable .from (listAllCubingJobs (cubeName , projectName , states , allOutputs , false )).transform (new Function <CubingJob , JobInstance >() {
202
- @ Override
203
- public JobInstance apply (CubingJob cubingJob ) {
204
- return parseToJobInstance (cubingJob , allOutputs );
205
- }
206
- }));
207
- }
208
-
209
141
private Set <ExecutableState > convertStatusEnumToStates (List <JobStatusEnum > statusList ) {
210
142
Set <ExecutableState > states ;
211
143
if (statusList == null || statusList .isEmpty ()) {
@@ -484,11 +416,44 @@ public JobInstance pauseJob(JobInstance job) throws IOException, JobException {
484
416
return job ;
485
417
}
486
418
487
- public List <CubingJob > listAllCubingJobs (final String cubeName , final String projectName , final Set <ExecutableState > statusList , final Map <String , Output > allOutputs , final boolean bEqual ) {
488
- return listAllCubingJobs (cubeName , projectName , statusList , 0L , Long .MAX_VALUE , allOutputs , bEqual );
419
+ /**
420
+ * currently only support substring match
421
+ * @return
422
+ */
423
+ public List <JobInstance > searchJobs (final String cubeNameSubstring , final String projectName , final List <JobStatusEnum > statusList , final Integer limitValue , final Integer offsetValue , final JobTimeFilterEnum timeFilter ) throws IOException , JobException {
424
+ Integer limit = (null == limitValue ) ? 30 : limitValue ;
425
+ Integer offset = (null == offsetValue ) ? 0 : offsetValue ;
426
+ List <JobInstance > jobs = searchJobs (cubeNameSubstring , projectName , statusList , timeFilter );
427
+ Collections .sort (jobs );
428
+
429
+ if (jobs .size () <= offset ) {
430
+ return Collections .emptyList ();
431
+ }
432
+
433
+ if ((jobs .size () - offset ) < limit ) {
434
+ return jobs .subList (offset , jobs .size ());
435
+ }
436
+
437
+ return jobs .subList (offset , offset + limit );
438
+ }
439
+
440
+ private List <JobInstance > searchJobs (final String cubeNameSubstring , final String projectName , final List <JobStatusEnum > statusList , final JobTimeFilterEnum timeFilter ) {
441
+ Calendar calendar = Calendar .getInstance ();
442
+ calendar .setTime (new Date ());
443
+ long timeStartInMillis = getTimeStartInMillis (calendar , timeFilter );
444
+
445
+ long timeEndInMillis = Long .MAX_VALUE ;
446
+ Set <ExecutableState > states = convertStatusEnumToStates (statusList );
447
+ final Map <String , Output > allOutputs = getExecutableManager ().getAllOutputs (timeStartInMillis , timeEndInMillis );
448
+ return Lists .newArrayList (FluentIterable .from (searchCubingJobs (cubeNameSubstring , projectName , states , timeStartInMillis , timeEndInMillis , allOutputs , false )).transform (new Function <CubingJob , JobInstance >() {
449
+ @ Override
450
+ public JobInstance apply (CubingJob cubingJob ) {
451
+ return parseToJobInstance (cubingJob , allOutputs );
452
+ }
453
+ }));
489
454
}
490
455
491
- public List <CubingJob > listAllCubingJobs (final String cubeName , final String projectName , final Set <ExecutableState > statusList , long timeStartInMillis , long timeEndInMillis , final Map <String , Output > allOutputs , final boolean bEqual ) {
456
+ public List <CubingJob > searchCubingJobs (final String cubeName , final String projectName , final Set <ExecutableState > statusList , long timeStartInMillis , long timeEndInMillis , final Map <String , Output > allOutputs , final boolean cubeNameExactMatch ) {
492
457
List <CubingJob > results = Lists .newArrayList (FluentIterable .from (getExecutableManager ().getAllAbstractExecutables (timeStartInMillis , timeEndInMillis , CubingJob .class )).filter (new Predicate <AbstractExecutable >() {
493
458
@ Override
494
459
public boolean apply (AbstractExecutable executable ) {
@@ -499,7 +464,7 @@ public boolean apply(AbstractExecutable executable) {
499
464
String executableCubeName = CubingExecutableUtil .getCubeName (executable .getParams ());
500
465
if (executableCubeName == null )
501
466
return true ;
502
- if (bEqual )
467
+ if (cubeNameExactMatch )
503
468
return executableCubeName .equalsIgnoreCase (cubeName );
504
469
else
505
470
return executableCubeName .contains (cubeName );
@@ -537,15 +502,12 @@ public boolean apply(CubingJob executable) {
537
502
return results ;
538
503
}
539
504
540
- public List <CubingJob > listAllCubingJobs (final String cubeName , final String projectName , final Set <ExecutableState > statusList , final boolean bEqual ) {
541
- return listAllCubingJobs (cubeName , projectName , statusList , getExecutableManager ().getAllOutputs (), bEqual );
542
- }
543
-
544
505
public List <CubingJob > listAllCubingJobs (final String cubeName , final String projectName , final Set <ExecutableState > statusList ) {
545
- return listAllCubingJobs (cubeName , projectName , statusList , getExecutableManager ().getAllOutputs (), false );
506
+ return searchCubingJobs (cubeName , projectName , statusList , 0L , Long . MAX_VALUE , getExecutableManager ().getAllOutputs (), true );
546
507
}
547
508
548
509
public List <CubingJob > listAllCubingJobs (final String cubeName , final String projectName ) {
549
- return listAllCubingJobs (cubeName , projectName , EnumSet .allOf (ExecutableState .class ), getExecutableManager ().getAllOutputs (), false );
510
+ return searchCubingJobs (cubeName , projectName , EnumSet .allOf (ExecutableState .class ), 0L , Long . MAX_VALUE , getExecutableManager ().getAllOutputs (), true );
550
511
}
512
+
551
513
}
0 commit comments