Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
5d52ccbb
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
5d52ccbb
编写于
3月 05, 2019
作者:
B
Boyang Jerry Peng
提交者:
Matteo Merli
3月 29, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix function termination cleanup (#3751)
* fix function termination cleanup * cleaning up
上级
0dba8035
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
3 deletion
+67
-3
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionInstanceId.java
...org/apache/pulsar/functions/utils/FunctionInstanceId.java
+50
-0
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/Utils.java
...rc/main/java/org/apache/pulsar/functions/utils/Utils.java
+0
-1
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java
...pache/pulsar/functions/worker/FunctionRuntimeManager.java
+17
-2
未找到文件。
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionInstanceId.java
0 → 100644
浏览文件 @
5d52ccbb
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.pulsar.functions.utils
;
import
lombok.Data
;
@Data
public
class
FunctionInstanceId
{
private
String
tenant
;
private
String
namespace
;
private
String
name
;
private
int
instanceId
;
public
FunctionInstanceId
(
String
fullyQualifiedInstanceName
)
{
String
[]
t1
=
fullyQualifiedInstanceName
.
split
(
"/"
);
if
(
t1
.
length
!=
3
)
{
throw
new
IllegalArgumentException
(
"Invalid format for fully qualified instance name: "
+
fullyQualifiedInstanceName
);
}
this
.
tenant
=
t1
[
0
];
this
.
namespace
=
t1
[
1
];
String
[]
t2
=
t1
[
2
].
split
(
":"
);
if
(
t2
.
length
!=
2
)
{
throw
new
IllegalArgumentException
(
"Invalid format for fully qualified instance name: "
+
fullyQualifiedInstanceName
);
}
this
.
name
=
t2
[
0
];
this
.
instanceId
=
Integer
.
parseInt
(
t2
[
1
]);
}
}
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/Utils.java
浏览文件 @
5d52ccbb
...
...
@@ -32,7 +32,6 @@ import java.nio.file.Path;
import
java.util.Collection
;
import
java.util.Collections
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.pulsar.common.functions.FunctionConfig
;
import
org.apache.pulsar.common.nar.NarClassLoader
;
import
org.apache.pulsar.functions.api.Function
;
...
...
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java
浏览文件 @
5d52ccbb
...
...
@@ -42,6 +42,7 @@ import org.apache.pulsar.functions.runtime.ThreadRuntimeFactory;
import
org.apache.pulsar.functions.secretsprovider.ClearTextSecretsProvider
;
import
org.apache.pulsar.functions.secretsproviderconfigurator.DefaultSecretsProviderConfigurator
;
import
org.apache.pulsar.functions.secretsproviderconfigurator.SecretsProviderConfigurator
;
import
org.apache.pulsar.functions.utils.FunctionInstanceId
;
import
org.apache.pulsar.functions.utils.Reflections
;
import
javax.ws.rs.WebApplicationException
;
...
...
@@ -291,7 +292,6 @@ public class FunctionRuntimeManager implements AutoCloseable{
return
assignments
;
}
/**
* Removes a collection of assignments
* @param assignments assignments to remove
...
...
@@ -693,7 +693,22 @@ public class FunctionRuntimeManager implements AutoCloseable{
this
.
conditionallyStopFunction
(
functionRuntimeInfo
);
}
else
{
// function doesn't exist anymore thus we should terminate
this
.
conditionallyTerminateFunction
(
functionRuntimeInfo
);
FunctionInstanceId
functionInstanceId
=
new
FunctionInstanceId
(
fullyQualifiedInstanceId
);
String
name
=
functionInstanceId
.
getName
();
String
namespace
=
functionInstanceId
.
getNamespace
();
String
tenant
=
functionInstanceId
.
getTenant
();
// only run the termination logic if
// this is the last/only instance from a function left on the worker
Collection
<
Assignment
>
assignments
=
findFunctionAssignments
(
tenant
,
namespace
,
name
,
this
.
workerIdToAssignments
);
if
(
assignments
.
size
()
>
1
)
{
this
.
conditionallyStopFunction
(
functionRuntimeInfo
);
}
else
{
this
.
conditionallyTerminateFunction
(
functionRuntimeInfo
);
}
}
this
.
functionRuntimeInfoMap
.
remove
(
fullyQualifiedInstanceId
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录