Skip to content

Commit

Permalink
add bml
Browse files Browse the repository at this point in the history
  • Loading branch information
peacewong committed Sep 8, 2023
1 parent e88d5b5 commit 5e52f90
Show file tree
Hide file tree
Showing 14 changed files with 842 additions and 42 deletions.
24 changes: 4 additions & 20 deletions linkis-extensions/linkis-et-monitor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@

<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-wedatasphere-common</artifactId>
<artifactId>linkis-storage</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-module</artifactId>
<artifactId>linkis-rpc</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
Expand All @@ -68,30 +68,14 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-computation-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-bml-cleaner</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-storage</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.linkis</groupId>
<artifactId>linkis-rpc</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.scan.app.bml.cleaner.dao;

import org.apache.linkis.monitor.scan.app.bml.cleaner.entity.CleanedResourceVersion;
import org.apache.linkis.monitor.scan.app.bml.cleaner.entity.ResourceVersion;
import org.apache.linkis.monitor.scan.app.bml.cleaner.vo.CleanResourceVo;

import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

public interface VersionDao {

@Select(
"select resource_id, count(resource_id) as version_count, max(version) as max_version from "
+ "linkis_ps_bml_resources_version lpbrv where start_time < #{startTime} GROUP BY resource_id HAVING count(resource_id) > #{maxVersionNum} limit #{limitNum}")
List<CleanResourceVo> getAllNeedCleanResource(
@Param("maxVersionNum") Integer maxVersionNum,
@Param("startTime") Date startTime,
@Param("limitNum") int num);

@Select(
"select * from linkis_ps_bml_resources_version where resource_id = #{resourceId} and version < #{minKeepVersion} and version <> 'v000001'")
List<ResourceVersion> getCleanVersionsByResourceId(
@Param("resourceId") String resourceId, @Param("minKeepVersion") String minKeepVersion);

@Insert({
"insert into linkis_ps_bml_cleaned_resources_version(`resource_id`,`file_md5`,`version`,`size`,`start_byte`, `end_byte`,`resource`,`description`,"
+ "`start_time`,`end_time`,`client_ip`,`updator`,`enable_flag`,`old_resource`) values(#{resourceId},#{fileMd5},#{version},#{size},#{startByte},#{endByte}"
+ ",#{resource},#{description},#{startTime},#{endTime},#{clientIp},#{updator},#{enableFlag},#{oldResource})"
})
@Options(useGeneratedKeys = true, keyProperty = "id")
void insertCleanResourceVersion(CleanedResourceVersion cleanedResourceVersion);

@Delete("delete from linkis_ps_bml_resources_version where id=#{id}")
void deleteResourceVersionById(@Param("id") long id);

@Select(
"select version from linkis_ps_bml_resources_version where resource_id =#{resourceId} and version <= #{maxVersion} order by version desc limit #{keepNum},1")
String getMinKeepVersion(
@Param("resourceId") String resourceId,
@Param("maxVersion") String maxVersion,
@Param("keepNum") int keepNum);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
/*
* 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.scan.app.bml.cleaner.entity;

import java.util.Date;

public class CleanedResourceVersion {

private long id;

private String resourceId;

private String fileMd5;

private String version;

private long size;

private String resource;

private String oldResource;

private String description;

private String clientIp;

private boolean enableFlag;

private String user;

private String system;

private Date startTime;

private Date endTime;

private long startByte;

private long endByte;

private String updator;

public String getResourceId() {
return resourceId;
}

public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

public String getSystem() {
return system;
}

public void setSystem(String system) {
this.system = system;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public String getResource() {
return resource;
}

public void setResource(String resource) {
this.resource = resource;
}

public String getOldResource() {
return oldResource;
}

public void setOldResource(String oldResource) {
this.oldResource = oldResource;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getFileMd5() {
return fileMd5;
}

public void setFileMd5(String fileMd5) {
this.fileMd5 = fileMd5;
}

public long getSize() {
return size;
}

public void setSize(long size) {
this.size = size;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getClientIp() {
return clientIp;
}

public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}

public boolean isEnableFlag() {
return enableFlag;
}

public void setEnableFlag(boolean enableFlag) {
this.enableFlag = enableFlag;
}

public long getStartByte() {
return startByte;
}

public void setStartByte(long startByte) {
this.startByte = startByte;
}

public long getEndByte() {
return endByte;
}

public void setEndByte(long endByte) {
this.endByte = endByte;
}

public Date getStartTime() {
return startTime;
}

public void setStartTime(Date startTime) {
this.startTime = startTime;
}

public Date getEndTime() {
return endTime;
}

public void setEndTime(Date endTime) {
this.endTime = endTime;
}

public String getUpdator() {
return updator;
}

public void setUpdator(String updator) {
this.updator = updator;
}

public static CleanedResourceVersion copyFromResourceVersion(ResourceVersion resourceVersion) {
CleanedResourceVersion cleanedResourceVersion = new CleanedResourceVersion();
cleanedResourceVersion.setResourceId(resourceVersion.getResourceId());
cleanedResourceVersion.setOldResource(resourceVersion.getResource());
cleanedResourceVersion.setFileMd5(resourceVersion.getFileMd5());
cleanedResourceVersion.setClientIp(resourceVersion.getClientIp());
cleanedResourceVersion.setSize(resourceVersion.getSize());
cleanedResourceVersion.setEnableFlag(resourceVersion.getEnableFlag());
cleanedResourceVersion.setVersion(resourceVersion.getVersion());
cleanedResourceVersion.setStartByte(resourceVersion.getStartByte());
cleanedResourceVersion.setEndByte(resourceVersion.getEndByte());
cleanedResourceVersion.setStartTime(resourceVersion.getStartTime());
cleanedResourceVersion.setEndTime(resourceVersion.getEndTime());
return cleanedResourceVersion;
}
}
Loading

0 comments on commit 5e52f90

Please sign in to comment.