Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
a6e01f77
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a6e01f77
编写于
12月 18, 2013
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-21078] Optimizing loadIdOnDisk.
上级
358fe7fe
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
32 deletion
+32
-32
changelog.html
changelog.html
+3
-0
core/src/main/java/hudson/model/RunMap.java
core/src/main/java/hudson/model/RunMap.java
+8
-11
core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
.../main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
+21
-21
未找到文件。
changelog.html
浏览文件 @
a6e01f77
...
...
@@ -61,6 +61,9 @@ Upcoming changes</a>
<li
class=
bug
>
Better robustness against XML deserialization errors.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-21024"
>
issue 21024
</a>
)
<li
class=
bug
>
Minimizing disk I/O while loading the
<em>
names
</em>
of build records during Jenkins startup.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-21078"
>
issue 21078
</a>
)
<li
class=
bug
>
Avoiding serializing the owning build as part of a test result action, as this can lead to errors later.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-18410"
>
issue 18410
</a>
)
...
...
core/src/main/java/hudson/model/RunMap.java
浏览文件 @
a6e01f77
...
...
@@ -194,24 +194,21 @@ public final class RunMap<R extends Run<?,R>> extends AbstractLazyLoadRunMap<R>
final
SimpleDateFormat
formatter
=
Run
.
ID_FORMATTER
.
get
();
return
new
FilenameFilter
()
{
public
boolean
accept
(
File
dir
,
String
name
)
{
// JENKINS-1461 sometimes create bogus data directories with impossible dates, such as year 0, April 31st,
// or August 0th. Date object doesn't roundtrip those, so we eventually fail to load this data.
// Don't even bother trying.
if
(!
isCorrectDate
(
name
))
{
LOGGER
.
log
(
FINE
,
"Skipping {0}"
,
new
File
(
dir
,
name
));
@Override
public
boolean
accept
(
File
dir
,
String
name
)
{
if
(
name
.
startsWith
(
"0000"
))
{
// JENKINS-1461 sometimes create bogus data directories with impossible dates, such as year 0, April 31st,
// or August 0th. Date object doesn't roundtrip those, so we eventually fail to load this data.
// Don't even bother trying.
return
false
;
}
return
!
name
.
startsWith
(
"0000"
)
&&
new
File
(
dir
,
name
).
isDirectory
();
}
private
boolean
isCorrectDate
(
String
name
)
{
try
{
if
(
formatter
.
format
(
formatter
.
parse
(
name
)).
equals
(
name
))
if
(
formatter
.
format
(
formatter
.
parse
(
name
)).
equals
(
name
))
{
return
true
;
}
}
catch
(
ParseException
e
)
{
// fall through
}
LOGGER
.
log
(
FINE
,
"Skipping {0} in {1}"
,
new
Object
[]
{
name
,
dir
});
return
false
;
}
};
...
...
core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
浏览文件 @
a6e01f77
...
...
@@ -26,19 +26,15 @@ package jenkins.model.lazy;
import
hudson.model.Job
;
import
hudson.model.Run
;
import
hudson.model.RunMap
;
import
org.apache.commons.collections.keyvalue.DefaultMapEntry
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.io.IOException
;
import
java.lang.ref.Reference
;
import
java.util.AbstractMap
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.NoSuchElementException
;
import
java.util.Set
;
...
...
@@ -50,6 +46,9 @@ import javax.annotation.CheckForNull;
import
static
jenkins
.
model
.
lazy
.
AbstractLazyLoadRunMap
.
Direction
.*;
import
static
jenkins
.
model
.
lazy
.
Boundary
.*;
import
org.apache.commons.collections.keyvalue.DefaultMapEntry
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
/**
* {@link SortedMap} that keeps build records by their build numbers, in the descending order
...
...
@@ -224,26 +223,27 @@ public abstract class AbstractLazyLoadRunMap<R> extends AbstractMap<Integer,R> i
}
private
void
loadIdOnDisk
()
{
String
[]
buildDirs
=
dir
.
list
(
createDirectoryFilter
()
);
if
(
buildDirs
==
null
)
{
String
[]
kids
=
dir
.
list
(
);
if
(
kids
==
null
)
{
// the job may have just been created
buildDirs
=
EMPTY_STRING_ARRAY
;
kids
=
EMPTY_STRING_ARRAY
;
}
// wrap into ArrayList to enable mutation
Arrays
.
sort
(
buildDirs
);
idOnDisk
=
new
SortedList
<
String
>(
new
ArrayList
<
String
>(
Arrays
.
asList
(
buildDirs
)));
// TODO: should we check that shortcuts is a symlink?
String
[]
shortcuts
=
dir
.
list
();
if
(
shortcuts
==
null
)
shortcuts
=
EMPTY_STRING_ARRAY
;
SortedIntList
list
=
new
SortedIntList
(
shortcuts
.
length
/
2
);
for
(
String
s
:
shortcuts
)
{
try
{
list
.
add
(
Integer
.
parseInt
(
s
));
}
catch
(
NumberFormatException
e
)
{
// this isn't a shortcut
List
<
String
>
buildDirs
=
new
ArrayList
<
String
>();
FilenameFilter
buildDirFilter
=
createDirectoryFilter
();
SortedIntList
list
=
new
SortedIntList
(
kids
.
length
/
2
);
for
(
String
s
:
kids
)
{
if
(
buildDirFilter
.
accept
(
dir
,
s
))
{
buildDirs
.
add
(
s
);
}
else
{
try
{
list
.
add
(
Integer
.
parseInt
(
s
));
}
catch
(
NumberFormatException
e
)
{
// this isn't a shortcut
}
}
}
Collections
.
sort
(
buildDirs
);
idOnDisk
=
new
SortedList
<
String
>(
buildDirs
);
list
.
sort
();
numberOnDisk
=
list
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录