Skip to content

Commit 00209f2

Browse files
committed
add entry class and instance path
1 parent d4d39ad commit 00209f2

File tree

12 files changed

+157
-61
lines changed

12 files changed

+157
-61
lines changed

api/compute/v1alpha1/common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ type JavaRuntime struct {
247247
ExtraDependenciesDir string `json:"extraDependenciesDir,omitempty"`
248248
Log *RuntimeLogConfig `json:"log,omitempty"`
249249
JavaOpts []string `json:"javaOpts,omitempty"`
250+
InstancePath *string `json:"instancePath,omitempty"`
251+
EntryClass *string `json:"entryClass,omitempty"`
250252
}
251253

252254
// PythonRuntime contains the python runtime configs

api/compute/v1alpha1/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/compute.functionmesh.io_functionmeshes.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,12 @@ spec:
198198
type: object
199199
java:
200200
properties:
201+
entryClass:
202+
type: string
201203
extraDependenciesDir:
202204
type: string
205+
instancePath:
206+
type: string
203207
jar:
204208
type: string
205209
jarLocation:
@@ -4185,8 +4189,12 @@ spec:
41854189
type: object
41864190
java:
41874191
properties:
4192+
entryClass:
4193+
type: string
41884194
extraDependenciesDir:
41894195
type: string
4196+
instancePath:
4197+
type: string
41904198
jar:
41914199
type: string
41924200
jarLocation:
@@ -7784,8 +7792,12 @@ spec:
77847792
type: string
77857793
java:
77867794
properties:
7795+
entryClass:
7796+
type: string
77877797
extraDependenciesDir:
77887798
type: string
7799+
instancePath:
7800+
type: string
77897801
jar:
77907802
type: string
77917803
jarLocation:

config/crd/bases/compute.functionmesh.io_functions.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,12 @@ spec:
195195
type: object
196196
java:
197197
properties:
198+
entryClass:
199+
type: string
198200
extraDependenciesDir:
199201
type: string
202+
instancePath:
203+
type: string
200204
jar:
201205
type: string
202206
jarLocation:

config/crd/bases/compute.functionmesh.io_sinks.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ spec:
190190
type: object
191191
java:
192192
properties:
193+
entryClass:
194+
type: string
193195
extraDependenciesDir:
194196
type: string
197+
instancePath:
198+
type: string
195199
jar:
196200
type: string
197201
jarLocation:

config/crd/bases/compute.functionmesh.io_sources.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ spec:
124124
type: string
125125
java:
126126
properties:
127+
entryClass:
128+
type: string
127129
extraDependenciesDir:
128130
type: string
131+
instancePath:
132+
type: string
129133
jar:
130134
type: string
131135
jarLocation:

controllers/spec/common.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ const (
134134
FunctionContainerName = "pulsar-function"
135135
SinkContainerName = "pulsar-sink"
136136
SourceContainerName = "pulsar-source"
137+
138+
DefaultPulsarFunctionsJavaInstancePath = "/pulsar/instances/java-instance.jar"
139+
DefaultPulsarFunctionsJavaInstanceEntryClass = "org.apache.pulsar.functions.instance.JavaInstanceMain"
137140
)
138141

139142
//go:embed template/java-runtime-log4j.xml.tmpl
@@ -538,11 +541,11 @@ func MakeJavaFunctionCommand(downloadPath, packageFile, name, clusterName, gener
538541
memory *resource.Quantity, javaOpts []string, hasPulsarctl, hasWget, authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef,
539542
state *v1alpha1.Stateful,
540543
tlsConfig TLSConfig, authConfig *v1alpha1.AuthConfig,
541-
maxPendingAsyncRequests *int32, logConfigFileName string) []string {
544+
maxPendingAsyncRequests *int32, logConfigFileName, instancePath, entryClass string) []string {
542545
processCommand := setShardIDEnvironmentVariableCommand() + " && " + generateLogConfigCommand +
543546
strings.Join(getProcessJavaRuntimeArgs(name, packageFile, clusterName, logLevel, details,
544547
extraDependenciesDir, connectorsDirectory, uid, memory, javaOpts, authProvided, tlsProvided, secretMaps, state, tlsConfig,
545-
authConfig, maxPendingAsyncRequests, logConfigFileName), " ")
548+
authConfig, maxPendingAsyncRequests, logConfigFileName, instancePath, entryClass), " ")
546549
if downloadPath != "" && !utils.EnableInitContainers {
547550
// prepend download command if the downPath is provided
548551
downloadCommand := strings.Join(GetDownloadCommand(downloadPath, packageFile, hasPulsarctl, hasWget,
@@ -1287,8 +1290,8 @@ func getProcessJavaRuntimeArgs(name, packageName, clusterName, logLevel, details
12871290
memory *resource.Quantity, javaOpts []string, authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef,
12881291
state *v1alpha1.Stateful,
12891292
tlsConfig TLSConfig, authConfig *v1alpha1.AuthConfig,
1290-
maxPendingAsyncRequests *int32, logConfigFileName string) []string {
1291-
classPath := "/pulsar/instances/java-instance.jar:$(echo /pulsar/lib/com.fasterxml.jackson.dataformat-jackson-dataformat-yaml-*.jar):$(echo /pulsar/lib/org.yaml-snakeyaml-*.jar)"
1293+
maxPendingAsyncRequests *int32, logConfigFileName, instancePath, entryClass string) []string {
1294+
classPath := fmt.Sprintf("%s:$(echo /pulsar/lib/com.fasterxml.jackson.dataformat-jackson-dataformat-yaml-*.jar):$(echo /pulsar/lib/org.yaml-snakeyaml-*.jar)", instancePath)
12921295
javaLogConfigPath := logConfigFileName
12931296
if javaLogConfigPath == "" {
12941297
javaLogConfigPath = DefaultJavaLogConfigPath
@@ -1327,7 +1330,7 @@ func getProcessJavaRuntimeArgs(name, packageName, clusterName, logLevel, details
13271330
"-XX:+ExitOnOutOfMemoryError",
13281331
"-Xlog:gc*:file=/pulsar/logs/gc.log:time,level,tags:filecount=5,filesize=10M",
13291332
strings.Join(javaOpts, " "),
1330-
"org.apache.pulsar.functions.instance.JavaInstanceMain",
1333+
entryClass,
13311334
"--jar",
13321335
packageName,
13331336
}

controllers/spec/function.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ func makeFunctionCommand(function *v1alpha1.Function) []string {
237237
if spec.Java != nil {
238238
if spec.Java.Jar != "" {
239239
mountPath := extractMountPath(spec.Java.Jar)
240+
instancePath := DefaultPulsarFunctionsJavaInstancePath
241+
if spec.Java.InstancePath != nil && *spec.Java.InstancePath != "" {
242+
instancePath = *spec.Java.InstancePath
243+
}
244+
entryClass := DefaultPulsarFunctionsJavaInstanceEntryClass
245+
if spec.Java.EntryClass != nil && *spec.Java.EntryClass != "" {
246+
entryClass = *spec.Java.EntryClass
247+
}
240248
return MakeJavaFunctionCommand(spec.Java.JarLocation, mountPath,
241249
spec.Name, spec.ClusterName,
242250
GenerateJavaLogConfigCommand(spec.Java, spec.LogTopicAgent),
@@ -250,7 +258,7 @@ func makeFunctionCommand(function *v1alpha1.Function) []string {
250258
spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "",
251259
spec.SecretsMap, spec.StateConfig, spec.Pulsar.TLSConfig,
252260
spec.Pulsar.AuthConfig, spec.MaxPendingAsyncRequests,
253-
GenerateJavaLogConfigFileName(function.Spec.Java))
261+
GenerateJavaLogConfigFileName(function.Spec.Java), instancePath, entryClass)
254262
}
255263
} else if spec.Python != nil {
256264
if spec.Python.Py != "" {

controllers/spec/sink.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ func MakeSinkCommand(sink *v1alpha1.Sink) []string {
227227
hasWget = true
228228
}
229229
mountPath := extractMountPath(spec.Java.Jar)
230+
instancePath := DefaultPulsarFunctionsJavaInstancePath
231+
if spec.Java.InstancePath != nil && *spec.Java.InstancePath != "" {
232+
instancePath = *spec.Java.InstancePath
233+
}
234+
entryClass := DefaultPulsarFunctionsJavaInstanceEntryClass
235+
if spec.Java.EntryClass != nil && *spec.Java.EntryClass != "" {
236+
entryClass = *spec.Java.EntryClass
237+
}
230238
return MakeJavaFunctionCommand(spec.Java.JarLocation, mountPath,
231239
spec.Name, spec.ClusterName,
232240
GenerateJavaLogConfigCommand(spec.Java, spec.LogTopicAgent),
@@ -238,7 +246,7 @@ func MakeSinkCommand(sink *v1alpha1.Sink) []string {
238246
spec.Resources.Limits.Memory(),
239247
spec.Java.JavaOpts, hasPulsarctl, hasWget, spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "",
240248
spec.SecretsMap, spec.StateConfig, spec.Pulsar.TLSConfig, spec.Pulsar.AuthConfig, nil,
241-
GenerateJavaLogConfigFileName(spec.Java))
249+
GenerateJavaLogConfigFileName(spec.Java), instancePath, entryClass)
242250
}
243251

244252
func generateSinkDetailsInJSON(sink *v1alpha1.Sink) string {

controllers/spec/source.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ func makeSourceCommand(source *v1alpha1.Source) []string {
174174
}
175175

176176
mountPath := extractMountPath(spec.Java.Jar)
177+
instancePath := DefaultPulsarFunctionsJavaInstancePath
178+
if spec.Java.InstancePath != nil && *spec.Java.InstancePath != "" {
179+
instancePath = *spec.Java.InstancePath
180+
}
181+
entryClass := DefaultPulsarFunctionsJavaInstanceEntryClass
182+
if spec.Java.EntryClass != nil && *spec.Java.EntryClass != "" {
183+
entryClass = *spec.Java.EntryClass
184+
}
177185
return MakeJavaFunctionCommand(spec.Java.JarLocation, mountPath,
178186
spec.Name, spec.ClusterName,
179187
GenerateJavaLogConfigCommand(spec.Java, spec.LogTopicAgent),
@@ -185,7 +193,7 @@ func makeSourceCommand(source *v1alpha1.Source) []string {
185193
spec.Resources.Limits.Memory(),
186194
spec.Java.JavaOpts, hasPulsarctl, hasWget, spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "",
187195
spec.SecretsMap, spec.StateConfig, spec.Pulsar.TLSConfig, spec.Pulsar.AuthConfig, nil,
188-
GenerateJavaLogConfigFileName(spec.Java))
196+
GenerateJavaLogConfigFileName(spec.Java), instancePath, entryClass)
189197
}
190198

191199
func generateSourceDetailsInJSON(source *v1alpha1.Source) string {

0 commit comments

Comments
 (0)