-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,791 additions
and
197 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
...itor/src/main/java/org/apache/linkis/monitor/department/dao/UserDepartmentInfoMapper.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,45 @@ | ||
/* | ||
* 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.monitor.department.dao; | ||
|
||
import org.apache.linkis.monitor.department.entity.UserDepartmentInfo; | ||
|
||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
|
||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@Mapper | ||
public interface UserDepartmentInfoMapper { | ||
|
||
void insertUser(UserDepartmentInfo user); | ||
|
||
@Transactional(rollbackFor = Exception.class) | ||
int batchInsertUsers(@Param("userDepartmentInfos") List<UserDepartmentInfo> userDepartmentInfos); | ||
|
||
void updateUser(UserDepartmentInfo user); | ||
|
||
UserDepartmentInfo selectUser(@Param("userName") String userName); | ||
|
||
@Transactional(rollbackFor = Exception.class) | ||
void deleteUser(); | ||
|
||
List<UserDepartmentInfo> selectAllUsers(); | ||
} |
150 changes: 150 additions & 0 deletions
150
...monitor/src/main/java/org/apache/linkis/monitor/department/entity/UserDepartmentInfo.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,150 @@ | ||
/* | ||
* 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.monitor.department.entity; | ||
|
||
import java.util.Date; | ||
|
||
public class UserDepartmentInfo { | ||
|
||
private String clusterCode; | ||
|
||
private String userType; | ||
private String userName; | ||
private String orgId; | ||
private String orgName; | ||
private String queueName; | ||
private String dbName; | ||
private String interfaceUser; | ||
private String isUnionAnalyse; | ||
private Date createTime; | ||
private String userItsmNo; | ||
|
||
// 构造函数、getter和setter方法 | ||
public UserDepartmentInfo( | ||
String clusterCode, | ||
String userType, | ||
String userName, | ||
String orgId, | ||
String orgName, | ||
String queueName, | ||
String dbName, | ||
String interfaceUser, | ||
String isUnionAnalyse, | ||
Date createTime, | ||
String userItsmNo) { | ||
this.clusterCode = clusterCode; | ||
this.userType = userType; | ||
this.userName = userName; | ||
this.orgId = orgId; | ||
this.orgName = orgName; | ||
this.queueName = queueName; | ||
this.dbName = dbName; | ||
this.interfaceUser = interfaceUser; | ||
this.isUnionAnalyse = isUnionAnalyse; | ||
this.createTime = createTime; | ||
this.userItsmNo = userItsmNo; | ||
} | ||
|
||
public String getClusterCode() { | ||
return clusterCode; | ||
} | ||
|
||
public void setClusterCode(String clusterCode) { | ||
this.clusterCode = clusterCode; | ||
} | ||
|
||
public String getUserType() { | ||
return userType; | ||
} | ||
|
||
public void setUserType(String userType) { | ||
this.userType = userType; | ||
} | ||
|
||
public String getUserName() { | ||
return userName; | ||
} | ||
|
||
public void setUserName(String userName) { | ||
this.userName = userName; | ||
} | ||
|
||
public String getOrgId() { | ||
return orgId; | ||
} | ||
|
||
public void setOrgId(String orgId) { | ||
this.orgId = orgId; | ||
} | ||
|
||
public String getOrgName() { | ||
return orgName; | ||
} | ||
|
||
public void setOrgName(String orgName) { | ||
this.orgName = orgName; | ||
} | ||
|
||
public String getQueueName() { | ||
return queueName; | ||
} | ||
|
||
public void setQueueName(String queueName) { | ||
this.queueName = queueName; | ||
} | ||
|
||
public String getDbName() { | ||
return dbName; | ||
} | ||
|
||
public void setDbName(String dbName) { | ||
this.dbName = dbName; | ||
} | ||
|
||
public String getInterfaceUser() { | ||
return interfaceUser; | ||
} | ||
|
||
public void setInterfaceUser(String interfaceUser) { | ||
this.interfaceUser = interfaceUser; | ||
} | ||
|
||
public String getIsUnionAnalyse() { | ||
return isUnionAnalyse; | ||
} | ||
|
||
public void setIsUnionAnalyse(String isUnionAnalyse) { | ||
this.isUnionAnalyse = isUnionAnalyse; | ||
} | ||
|
||
public Date getCreateTime() { | ||
return createTime; | ||
} | ||
|
||
public void setCreateTime(Date createTime) { | ||
this.createTime = createTime; | ||
} | ||
|
||
public String getUserItsmNo() { | ||
return userItsmNo; | ||
} | ||
|
||
public void setUserItsmNo(String userItsmNo) { | ||
this.userItsmNo = userItsmNo; | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
...ons/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/entity/ClientSingleton.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,107 @@ | ||
/* | ||
* 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.monitor.entity; | ||
|
||
import org.apache.linkis.bml.conf.BmlConfiguration; | ||
import org.apache.linkis.common.conf.Configuration; | ||
import org.apache.linkis.httpclient.dws.authentication.TokenAuthenticationStrategy; | ||
import org.apache.linkis.httpclient.dws.config.DWSClientConfig; | ||
import org.apache.linkis.httpclient.dws.config.DWSClientConfigBuilder; | ||
import org.apache.linkis.monitor.client.MonitorHTTPClient; | ||
import org.apache.linkis.monitor.client.MonitorHTTPClientClientImpl; | ||
|
||
import org.apache.commons.collections.MapUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class ClientSingleton { | ||
private static MonitorHTTPClient instance; | ||
private static DWSClientConfig dwsClientConfig; | ||
|
||
private ClientSingleton() {} | ||
|
||
public static synchronized MonitorHTTPClient getInstance() { | ||
if (instance == null) { | ||
if (dwsClientConfig == null) { | ||
dwsClientConfig = createClientConfig(null, null); // NOSONAR | ||
} | ||
instance = new MonitorHTTPClientClientImpl(dwsClientConfig); | ||
} | ||
return instance; | ||
} | ||
|
||
public static DWSClientConfig createClientConfig(String url, Map<String, Object> properties) { | ||
String realUrl = ""; | ||
if (StringUtils.isBlank(url)) { | ||
realUrl = Configuration.getGateWayURL(); | ||
} else { | ||
realUrl = url; | ||
} | ||
Map<String, Object> parms = new HashMap<>(); | ||
if (MapUtils.isNotEmpty(properties)) { | ||
parms = properties; | ||
} | ||
int maxConnection = | ||
(int) | ||
parms.getOrDefault( // NOSONAR | ||
BmlConfiguration.CONNECTION_MAX_SIZE_SHORT_NAME(), | ||
BmlConfiguration.CONNECTION_MAX_SIZE().getValue()); | ||
int connectTimeout = | ||
(int) | ||
parms.getOrDefault( | ||
BmlConfiguration.CONNECTION_TIMEOUT_SHORT_NAME(), | ||
BmlConfiguration.CONNECTION_TIMEOUT().getValue()); | ||
int readTimeout = | ||
(int) | ||
parms.getOrDefault( | ||
BmlConfiguration.CONNECTION_READ_TIMEOUT_SHORT_NAME(), | ||
BmlConfiguration.CONNECTION_READ_TIMEOUT().getValue()); | ||
String tokenKey = | ||
(String) | ||
parms.getOrDefault( | ||
BmlConfiguration.AUTH_TOKEN_KEY_SHORT_NAME(), | ||
BmlConfiguration.AUTH_TOKEN_KEY().getValue()); | ||
String tokenValue = | ||
(String) | ||
parms.getOrDefault( | ||
BmlConfiguration.AUTH_TOKEN_VALUE_SHORT_NAME(), | ||
BmlConfiguration.AUTH_TOKEN_VALUE().getValue()); | ||
|
||
DWSClientConfig clientConfig = | ||
((DWSClientConfigBuilder) | ||
(DWSClientConfigBuilder.newBuilder() | ||
.addServerUrl(realUrl) | ||
.connectionTimeout(connectTimeout) | ||
.discoveryEnabled(false) | ||
.discoveryFrequency(1, TimeUnit.MINUTES) | ||
.loadbalancerEnabled(false) | ||
.maxConnectionSize(maxConnection) | ||
.retryEnabled(false) | ||
.readTimeout(readTimeout) | ||
.setAuthenticationStrategy(new TokenAuthenticationStrategy()) | ||
.setAuthTokenKey(tokenKey) | ||
.setAuthTokenValue(tokenValue))) | ||
.setDWSVersion("v1") | ||
.build(); | ||
|
||
return clientConfig; | ||
} | ||
} |
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
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
Oops, something went wrong.