-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translate engineconn-plugins-trino service classes from Scala to Java (…
- Loading branch information
1 parent
29cf010
commit 632191a
Showing
16 changed files
with
932 additions
and
808 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
...ugins/trino/src/main/java/org/apache/linkis/engineplugin/trino/TrinoEngineConnPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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.linkis.engineplugin.trino; | ||
|
||
import org.apache.linkis.engineplugin.trino.builder.TrinoProcessEngineConnLaunchBuilder; | ||
import org.apache.linkis.engineplugin.trino.factory.TrinoEngineConnFactory; | ||
import org.apache.linkis.manager.engineplugin.common.EngineConnPlugin; | ||
import org.apache.linkis.manager.engineplugin.common.creation.EngineConnFactory; | ||
import org.apache.linkis.manager.engineplugin.common.launch.EngineConnLaunchBuilder; | ||
import org.apache.linkis.manager.engineplugin.common.resource.EngineResourceFactory; | ||
import org.apache.linkis.manager.engineplugin.common.resource.GenericEngineResourceFactory; | ||
import org.apache.linkis.manager.label.entity.Label; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class TrinoEngineConnPlugin implements EngineConnPlugin { | ||
|
||
private Object resourceLocker = new Object(); | ||
private Object engineFactoryLocker = new Object(); | ||
private volatile EngineResourceFactory engineResourceFactory; | ||
private volatile EngineConnFactory engineFactory; | ||
private final List<Label<?>> defaultLabels = new ArrayList<>(); | ||
|
||
@Override | ||
public void init(Map<String, Object> params) {} | ||
|
||
@Override | ||
public EngineResourceFactory getEngineResourceFactory() { | ||
if (Objects.isNull(engineResourceFactory)) { | ||
synchronized (resourceLocker) { | ||
if (Objects.isNull(engineResourceFactory)) { | ||
engineResourceFactory = new GenericEngineResourceFactory(); | ||
} | ||
} | ||
} | ||
return engineResourceFactory; | ||
} | ||
|
||
@Override | ||
public EngineConnLaunchBuilder getEngineConnLaunchBuilder() { | ||
return new TrinoProcessEngineConnLaunchBuilder(); | ||
} | ||
|
||
@Override | ||
public EngineConnFactory getEngineConnFactory() { | ||
if (Objects.isNull(engineFactory)) { | ||
synchronized (engineFactoryLocker) { | ||
if (Objects.isNull(engineFactory)) { | ||
engineFactory = new TrinoEngineConnFactory(); | ||
} | ||
} | ||
} | ||
return engineFactory; | ||
} | ||
|
||
@Override | ||
public List<Label<?>> getDefaultLabels() { | ||
return defaultLabels; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...ins/trino/src/main/java/org/apache/linkis/engineplugin/trino/conf/TrinoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* 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.linkis.engineplugin.trino.conf; | ||
|
||
import org.apache.linkis.common.conf.CommonVars; | ||
import org.apache.linkis.storage.utils.StorageConfiguration; | ||
|
||
public class TrinoConfiguration { | ||
|
||
public static final CommonVars<Integer> ENGINE_CONCURRENT_LIMIT = | ||
CommonVars.apply("linkis.engineconn.concurrent.limit", 100); | ||
|
||
public static final CommonVars<Integer> DEFAULT_LIMIT = | ||
CommonVars.apply("linkis.trino.default.limit", 5000); | ||
|
||
public static final CommonVars<Long> TRINO_HTTP_CONNECT_TIME_OUT = | ||
CommonVars.apply("linkis.trino.http.connectTimeout.seconds", 60L); | ||
|
||
public static final CommonVars<Long> TRINO_HTTP_READ_TIME_OUT = | ||
CommonVars.apply("linkis.trino.http.readTimeout.seconds", 60L); | ||
|
||
public static final CommonVars<String> TRINO_URL = | ||
CommonVars.apply("linkis.trino.url", "http://127.0.0.1:8080"); | ||
|
||
public static final CommonVars<String> TRINO_PASSWORD = | ||
CommonVars.apply("linkis.trino.password", null); | ||
|
||
public static final CommonVars<String> TRINO_PASSWORD_CMD = | ||
CommonVars.apply("linkis.trino.password.cmd", null); | ||
|
||
public static final CommonVars<String> TRINO_CATALOG = | ||
CommonVars.apply("linkis.trino.catalog", "system"); | ||
|
||
public static final CommonVars<String> TRINO_SCHEMA = CommonVars.apply("linkis.trino.schema", ""); | ||
|
||
public static final CommonVars<String> TRINO_SOURCE = | ||
CommonVars.apply("linkis.trino.source", "global"); | ||
|
||
public static final CommonVars<Boolean> TRINO_SSL_INSECURED = | ||
CommonVars.apply("linkis.trino.ssl.insecured", true); | ||
|
||
public static final CommonVars<String> TRINO_SSL_KEYSTORE = | ||
CommonVars.apply("linkis.trino.ssl.keystore", null); | ||
|
||
public static final CommonVars<String> TRINO_SSL_KEYSTORE_TYPE = | ||
CommonVars.apply("linkis.trino.ssl.keystore.type", null); | ||
|
||
public static final CommonVars<String> TRINO_SSL_KEYSTORE_PASSWORD = | ||
CommonVars.apply("linkis.trino.ssl.keystore.password", null); | ||
|
||
public static final CommonVars<String> TRINO_SSL_TRUSTSTORE = | ||
CommonVars.apply("linkis.trino.ssl.truststore", null); | ||
|
||
public static final CommonVars<String> TRINO_SSL_TRUSTSTORE_TYPE = | ||
CommonVars.apply("linkis.trino.ssl.truststore.type", null); | ||
|
||
public static final CommonVars<String> TRINO_SSL_TRUSTSTORE_PASSWORD = | ||
CommonVars.apply("linkis.trino.ssl.truststore.password", null); | ||
|
||
public static final CommonVars<Boolean> TRINO_FORBID_GRANT = | ||
CommonVars.apply("linkis.trino.forbid.grant", true); | ||
|
||
public static final CommonVars<Boolean> TRINO_FORBID_MODIFY_SCHEMA = | ||
CommonVars.apply("linkis.trino.forbid.modifySchema", true); | ||
|
||
public static final CommonVars<Boolean> TRINO_USER_ISOLATION_MODE = | ||
CommonVars.apply("linkis.trino.user.isolation.mode", false); | ||
|
||
public static final CommonVars<String> TRINO_DEFAULT_USER = | ||
CommonVars.apply( | ||
"linkis.trino.default.start.user", StorageConfiguration.HDFS_ROOT_USER.getValue()); | ||
|
||
public static final CommonVars<Boolean> TRINO_SQL_HOOK_ENABLED = | ||
CommonVars.apply("linkis.trino.sql.hook.enabled", true, "trino sql hoook"); | ||
} |
53 changes: 53 additions & 0 deletions
53
...gins/trino/src/main/java/org/apache/linkis/engineplugin/trino/conf/TrinoEngineConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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.linkis.engineplugin.trino.conf; | ||
|
||
import org.apache.linkis.common.conf.Configuration; | ||
import org.apache.linkis.governance.common.protocol.conf.RequestQueryEngineConfigWithGlobalConfig; | ||
import org.apache.linkis.governance.common.protocol.conf.ResponseQueryConfig; | ||
import org.apache.linkis.manager.label.entity.engine.EngineTypeLabel; | ||
import org.apache.linkis.manager.label.entity.engine.UserCreatorLabel; | ||
import org.apache.linkis.protocol.CacheableProtocol; | ||
import org.apache.linkis.rpc.RPCMapCache; | ||
|
||
import java.util.Map; | ||
|
||
import scala.Tuple2; | ||
|
||
public class TrinoEngineConfig | ||
extends RPCMapCache<Tuple2<UserCreatorLabel, EngineTypeLabel>, String, String> { | ||
|
||
public TrinoEngineConfig() { | ||
super(Configuration.CLOUD_CONSOLE_CONFIGURATION_SPRING_APPLICATION_NAME().getValue()); | ||
} | ||
|
||
@Override | ||
public CacheableProtocol createRequest(Tuple2<UserCreatorLabel, EngineTypeLabel> labelTuple) { | ||
return new RequestQueryEngineConfigWithGlobalConfig(labelTuple._1(), labelTuple._2(), null); | ||
} | ||
|
||
@Override | ||
public Map<String, String> createMap(Object obj) { | ||
if (obj instanceof ResponseQueryConfig) { | ||
ResponseQueryConfig response = (ResponseQueryConfig) obj; | ||
return response.getKeyAndValue(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...no/src/main/java/org/apache/linkis/engineplugin/trino/exception/TrinoClientException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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.linkis.engineplugin.trino.exception; | ||
|
||
import org.apache.linkis.common.exception.ErrorException; | ||
|
||
public class TrinoClientException extends ErrorException { | ||
public TrinoClientException(String message) { | ||
super(60012, message); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...o/src/main/java/org/apache/linkis/engineplugin/trino/exception/TrinoGrantmaException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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.linkis.engineplugin.trino.exception; | ||
|
||
import org.apache.linkis.common.exception.ErrorException; | ||
|
||
public class TrinoGrantmaException extends ErrorException { | ||
public TrinoGrantmaException(String message) { | ||
super(60015, message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../main/java/org/apache/linkis/engineplugin/trino/exception/TrinoStateInvalidException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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.linkis.engineplugin.trino.exception; | ||
|
||
import org.apache.linkis.common.exception.ErrorException; | ||
|
||
public class TrinoStateInvalidException extends ErrorException { | ||
public TrinoStateInvalidException(String message) { | ||
super(60011, message); | ||
} | ||
} |
Oops, something went wrong.