Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
9114ddc1
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9114ddc1
编写于
2月 28, 2018
作者:
S
Sanjeev Kulkarni
提交者:
Sijie Guo
3月 03, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Moved localrun to process based runtime (#261)
上级
dc8f39c7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
40 deletion
+38
-40
pulsar-functions/cli/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
...c/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
+3
-5
pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/ProcessRuntimeFactory.java
...pache/pulsar/functions/runtime/ProcessRuntimeFactory.java
+35
-0
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionWorkerStarter.java
...apache/pulsar/functions/worker/FunctionWorkerStarter.java
+0
-35
未找到文件。
pulsar-functions/cli/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
浏览文件 @
9114ddc1
...
...
@@ -51,7 +51,7 @@ import org.apache.pulsar.functions.api.PulsarFunction;
import
org.apache.pulsar.functions.api.utils.DefaultSerDe
;
import
org.apache.pulsar.functions.proto.Function.FunctionConfig
;
import
org.apache.pulsar.functions.instance.InstanceConfig
;
import
org.apache.pulsar.functions.runtime.
Thread
RuntimeFactory
;
import
org.apache.pulsar.functions.runtime.
Process
RuntimeFactory
;
import
org.apache.pulsar.functions.api.SerDe
;
import
org.apache.pulsar.functions.runtime.RuntimeSpawner
;
import
org.apache.pulsar.functions.utils.FunctionConfigUtils
;
...
...
@@ -447,10 +447,8 @@ public class CmdFunctions extends CmdBase {
if
(
brokerServiceUrl
!=
null
)
{
serviceUrl
=
brokerServiceUrl
;
}
try
(
ThreadRuntimeFactory
containerFactory
=
new
ThreadRuntimeFactory
(
"LocalRunnerThreadGroup"
,
serviceUrl
,
stateStorageServiceUrl
))
{
try
(
ProcessRuntimeFactory
containerFactory
=
new
ProcessRuntimeFactory
(
serviceUrl
,
null
,
null
,
null
))
{
InstanceConfig
instanceConfig
=
new
InstanceConfig
();
instanceConfig
.
setFunctionConfig
(
functionConfig
);
...
...
pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/ProcessRuntimeFactory.java
浏览文件 @
9114ddc1
...
...
@@ -23,6 +23,8 @@ import com.google.common.annotations.VisibleForTesting;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.pulsar.functions.instance.InstanceConfig
;
import
java.nio.file.Paths
;
/**
* Thread based function container factory implementation.
*/
...
...
@@ -44,6 +46,39 @@ public class ProcessRuntimeFactory implements RuntimeFactory {
this
.
javaInstanceJarFile
=
javaInstanceJarFile
;
this
.
pythonInstanceFile
=
pythonInstanceFile
;
this
.
logDirectory
=
logDirectory
;
// if things are not specified, try to figure out by env properties
if
(
this
.
javaInstanceJarFile
==
null
)
{
String
envJavaInstanceJarLocation
=
System
.
getProperty
(
"pulsar.functions.java.instance.jar"
);
if
(
null
!=
envJavaInstanceJarLocation
)
{
log
.
info
(
"Java instance jar location is not defined,"
+
" using the location defined in system environment : {}"
,
envJavaInstanceJarLocation
);
this
.
javaInstanceJarFile
=
envJavaInstanceJarLocation
;
}
else
{
throw
new
RuntimeException
(
"No JavaInstanceJar specified"
);
}
}
if
(
this
.
pythonInstanceFile
==
null
)
{
String
envPythonInstanceLocation
=
System
.
getProperty
(
"pulsar.functions.python.instance.file"
);
if
(
null
!=
envPythonInstanceLocation
)
{
log
.
info
(
"Python instance file location is not defined"
+
" using the location defined in system environment : {}"
,
envPythonInstanceLocation
);
this
.
pythonInstanceFile
=
envPythonInstanceLocation
;
}
else
{
throw
new
RuntimeException
(
"No PythonInstanceFile specified"
);
}
}
if
(
this
.
logDirectory
==
null
)
{
String
envProcessContainerLogDirectory
=
System
.
getProperty
(
"pulsar.functions.process.container.log.dir"
);
if
(
null
!=
envProcessContainerLogDirectory
)
{
this
.
logDirectory
=
envProcessContainerLogDirectory
;
}
else
{
// use a default location
this
.
logDirectory
=
Paths
.
get
(
"logs"
).
toFile
().
getAbsolutePath
();
}
}
}
@Override
...
...
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionWorkerStarter.java
浏览文件 @
9114ddc1
...
...
@@ -22,7 +22,6 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
import
com.beust.jcommander.JCommander
;
import
com.beust.jcommander.Parameter
;
import
java.nio.file.Paths
;
import
lombok.extern.slf4j.Slf4j
;
/**
...
...
@@ -61,40 +60,6 @@ public class FunctionWorkerStarter {
}
else
{
workerConfig
=
WorkerConfig
.
load
(
workerArguments
.
configFile
);
}
// searching the java instance location if it is not defined
if
(
null
!=
workerConfig
.
getProcessContainerFactory
()
&&
null
==
workerConfig
.
getProcessContainerFactory
().
getJavaInstanceJarLocation
())
{
String
envJavaInstanceJarLocation
=
System
.
getProperty
(
"pulsar.functions.java.instance.jar"
);
if
(
null
!=
envJavaInstanceJarLocation
)
{
log
.
info
(
"Java instance jar location is not defined in worker config yml."
+
" Use the location defined in system environment : {}"
,
envJavaInstanceJarLocation
);
workerConfig
.
getProcessContainerFactory
().
setJavaInstanceJarLocation
(
envJavaInstanceJarLocation
);
}
}
if
(
null
!=
workerConfig
.
getProcessContainerFactory
()
&&
null
==
workerConfig
.
getProcessContainerFactory
().
getPythonInstanceLocation
())
{
String
envPythonInstanceLocation
=
System
.
getProperty
(
"pulsar.functions.python.instance.file"
);
if
(
null
!=
envPythonInstanceLocation
)
{
log
.
info
(
"Python instance file location is not defined in worker config yml."
+
" Use the location defined in system environment : {}"
,
envPythonInstanceLocation
);
workerConfig
.
getProcessContainerFactory
().
setPythonInstanceLocation
(
envPythonInstanceLocation
);
}
}
// config the log directory
if
(
null
!=
workerConfig
.
getProcessContainerFactory
()
&&
null
==
workerConfig
.
getProcessContainerFactory
().
getLogDirectory
())
{
String
envProcessContainerLogDirectory
=
System
.
getProperty
(
"pulsar.functions.process.container.log.dir"
);
if
(
null
!=
envProcessContainerLogDirectory
)
{
workerConfig
.
getProcessContainerFactory
().
setLogDirectory
(
envProcessContainerLogDirectory
);
}
else
{
// use a default location
workerConfig
.
getProcessContainerFactory
().
setLogDirectory
(
Paths
.
get
(
"logs"
).
toFile
().
getAbsolutePath
());
}
}
final
Worker
worker
=
new
Worker
(
workerConfig
);
worker
.
startAsync
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录