Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
c9cba277
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c9cba277
编写于
2月 25, 2016
作者:
U
Ufuk Celebi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-3512] [runtime] Savepoint backend should not revert to 'jobmanager'
This closes #1712.
上级
d90672fd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
50 deletion
+37
-50
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/SavepointStoreFactory.java
...pache/flink/runtime/checkpoint/SavepointStoreFactory.java
+21
-42
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/SavepointStoreFactoryTest.java
...e/flink/runtime/checkpoint/SavepointStoreFactoryTest.java
+16
-8
未找到文件。
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/SavepointStoreFactory.java
浏览文件 @
c9cba277
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
package
org.apache.flink.runtime.checkpoint
;
package
org.apache.flink.runtime.checkpoint
;
import
org.apache.flink.configuration.ConfigConstants
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.configuration.IllegalConfigurationException
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -32,6 +32,7 @@ public class SavepointStoreFactory {
...
@@ -32,6 +32,7 @@ public class SavepointStoreFactory {
public
static
final
String
SAVEPOINT_BACKEND_KEY
=
"savepoints.state.backend"
;
public
static
final
String
SAVEPOINT_BACKEND_KEY
=
"savepoints.state.backend"
;
public
static
final
String
SAVEPOINT_DIRECTORY_KEY
=
"savepoints.state.backend.fs.dir"
;
public
static
final
String
SAVEPOINT_DIRECTORY_KEY
=
"savepoints.state.backend.fs.dir"
;
public
static
final
String
DEFAULT_SAVEPOINT_BACKEND
=
"jobmanager"
;
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
SavepointStoreFactory
.
class
);
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
SavepointStoreFactory
.
class
);
...
@@ -52,55 +53,33 @@ public class SavepointStoreFactory {
...
@@ -52,55 +53,33 @@ public class SavepointStoreFactory {
Configuration
config
)
throws
Exception
{
Configuration
config
)
throws
Exception
{
// Try a the savepoint-specific configuration first.
// Try a the savepoint-specific configuration first.
String
savepointBackend
=
config
.
getString
(
SAVEPOINT_BACKEND_KEY
,
null
);
String
savepointBackend
=
config
.
getString
(
SAVEPOINT_BACKEND_KEY
,
DEFAULT_SAVEPOINT_BACKEND
);
if
(
savepointBackend
==
null
)
{
if
(
savepointBackend
==
null
)
{
LOG
.
info
(
"No savepoint state backend configured. "
+
LOG
.
info
(
"No savepoint state backend configured. "
+
"Using job manager savepoint state backend."
);
"Using job manager savepoint state backend."
);
return
createJobManagerSavepointStore
();
return
createJobManagerSavepointStore
();
}
}
else
if
(
savepointBackend
.
equals
(
"jobmanager"
))
{
else
if
(
savepointBackend
.
equals
(
"jobmanager"
))
{
LOG
.
info
(
"Using job manager savepoint state backend."
);
LOG
.
info
(
"Using job manager savepoint state backend."
);
return
createJobManagerSavepointStore
();
return
createJobManagerSavepointStore
();
}
}
else
if
(
savepointBackend
.
equals
(
"filesystem"
))
{
else
if
(
savepointBackend
.
equals
(
"filesystem"
))
{
String
rootPath
=
config
.
getString
(
SAVEPOINT_DIRECTORY_KEY
,
null
);
// Sanity check that the checkpoints are not stored on the job manager only
String
checkpointBackend
=
config
.
getString
(
if
(
rootPath
==
null
)
{
ConfigConstants
.
STATE_BACKEND
,
"jobmanager"
);
throw
new
IllegalConfigurationException
(
"Using filesystem as savepoint state backend, "
+
"but did not specify directory. Please set the "
+
if
(
checkpointBackend
.
equals
(
"jobmanager"
))
{
"following configuration key: '"
+
SAVEPOINT_DIRECTORY_KEY
+
LOG
.
warn
(
"The combination of file system backend for savepoints and
"
+
"' (e.g. "
+
SAVEPOINT_DIRECTORY_KEY
+
": hdfs:///flink/savepoints/).
"
+
"
jobmanager backend for checkpoints does not work. The savepoint "
+
"
Falling back to job manager savepoint backend."
);
"will *not* be recoverable after the job manager shuts down. "
+
}
else
{
"Falling back to job manager savepoint state backend."
);
LOG
.
info
(
"Using filesystem savepoint backend (root path: {})."
,
rootPath
);
return
create
JobManagerSavepointStore
(
);
return
create
FileSystemSavepointStore
(
rootPath
);
}
}
else
{
}
else
{
String
rootPath
=
config
.
getString
(
SAVEPOINT_DIRECTORY_KEY
,
null
);
throw
new
IllegalConfigurationException
(
"Unexpected savepoint backend "
+
"configuration '"
+
savepointBackend
+
"'. "
+
if
(
rootPath
==
null
)
{
"Falling back to job manager savepoint state backend."
);
LOG
.
warn
(
"Using filesystem as savepoint state backend, "
+
"but did not specify directory. Please set the "
+
"following configuration key: '"
+
SAVEPOINT_DIRECTORY_KEY
+
"' (e.g. "
+
SAVEPOINT_DIRECTORY_KEY
+
": hdfs:///flink/savepoints/). "
+
"Falling back to job manager savepoint backend."
);
return
createJobManagerSavepointStore
();
}
else
{
LOG
.
info
(
"Using filesystem savepoint backend (root path: {})."
,
rootPath
);
return
createFileSystemSavepointStore
(
rootPath
);
}
}
}
else
{
// Fallback
LOG
.
warn
(
"Unexpected savepoint backend configuration '{}'. "
+
"Falling back to job manager savepoint state backend."
,
savepointBackend
);
return
createJobManagerSavepointStore
();
}
}
}
}
...
...
flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/SavepointStoreFactoryTest.java
浏览文件 @
c9cba277
...
@@ -20,11 +20,13 @@ package org.apache.flink.runtime.checkpoint;
...
@@ -20,11 +20,13 @@ package org.apache.flink.runtime.checkpoint;
import
org.apache.flink.configuration.ConfigConstants
;
import
org.apache.flink.configuration.ConfigConstants
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.configuration.IllegalConfigurationException
;
import
org.apache.flink.core.fs.Path
;
import
org.apache.flink.core.fs.Path
;
import
org.junit.Test
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
fail
;
public
class
SavepointStoreFactoryTest
{
public
class
SavepointStoreFactoryTest
{
...
@@ -61,28 +63,34 @@ public class SavepointStoreFactoryTest {
...
@@ -61,28 +63,34 @@ public class SavepointStoreFactoryTest {
@Test
@Test
public
void
testSavepointBackendFileSystemButCheckpointBackendJobManager
()
throws
Exception
{
public
void
testSavepointBackendFileSystemButCheckpointBackendJobManager
()
throws
Exception
{
Configuration
config
=
new
Configuration
();
Configuration
config
=
new
Configuration
();
String
rootPath
=
System
.
getProperty
(
"java.io.tmpdir"
);
// This combination does not make sense, because the checkpoints will be
// This combination does not make sense, because the checkpoints will be
// lost after the job manager shuts down.
// lost after the job manager shuts down.
config
.
setString
(
ConfigConstants
.
STATE_BACKEND
,
"jobmanager"
);
config
.
setString
(
ConfigConstants
.
STATE_BACKEND
,
"jobmanager"
);
config
.
setString
(
SavepointStoreFactory
.
SAVEPOINT_BACKEND_KEY
,
"filesystem"
);
config
.
setString
(
SavepointStoreFactory
.
SAVEPOINT_BACKEND_KEY
,
"filesystem"
);
config
.
setString
(
SavepointStoreFactory
.
SAVEPOINT_DIRECTORY_KEY
,
rootPath
);
SavepointStore
store
=
SavepointStoreFactory
.
createFromConfig
(
config
);
SavepointStore
store
=
SavepointStoreFactory
.
createFromConfig
(
config
);
assertTrue
(
store
.
getStateStore
()
instanceof
HeapStateStore
);
assertTrue
(
store
.
getStateStore
()
instanceof
FileSystemStateStore
);
FileSystemStateStore
<
CompletedCheckpoint
>
stateStore
=
(
FileSystemStateStore
<
CompletedCheckpoint
>)
store
.
getStateStore
();
assertEquals
(
new
Path
(
rootPath
),
stateStore
.
getRootPath
());
}
}
@Test
@Test
(
expected
=
IllegalConfigurationException
.
class
)
public
void
testSavepointBackendFileSystemButNoDirectory
()
throws
Exception
{
public
void
testSavepointBackendFileSystemButNoDirectory
()
throws
Exception
{
Configuration
config
=
new
Configuration
();
Configuration
config
=
new
Configuration
();
config
.
setString
(
SavepointStoreFactory
.
SAVEPOINT_BACKEND_KEY
,
"filesystem"
);
config
.
setString
(
SavepointStoreFactory
.
SAVEPOINT_BACKEND_KEY
,
"filesystem"
);
SavepointStore
store
=
SavepointStore
Factory
.
createFromConfig
(
config
);
SavepointStoreFactory
.
createFromConfig
(
config
);
assertTrue
(
store
.
getStateStore
()
instanceof
HeapStateStore
);
fail
(
"Did not throw expected Exception"
);
}
}
@Test
@Test
(
expected
=
IllegalConfigurationException
.
class
)
public
void
testUnexpectedSavepointBackend
()
throws
Exception
{
public
void
testUnexpectedSavepointBackend
()
throws
Exception
{
Configuration
config
=
new
Configuration
();
Configuration
config
=
new
Configuration
();
config
.
setString
(
SavepointStoreFactory
.
SAVEPOINT_BACKEND_KEY
,
"unexpected"
);
config
.
setString
(
SavepointStoreFactory
.
SAVEPOINT_BACKEND_KEY
,
"unexpected"
);
SavepointStore
store
=
SavepointStore
Factory
.
createFromConfig
(
config
);
SavepointStoreFactory
.
createFromConfig
(
config
);
assertTrue
(
store
.
getStateStore
()
instanceof
HeapStateStore
);
fail
(
"Did not throw expected Exception"
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录