forked from apache/linkis
-
Notifications
You must be signed in to change notification settings - Fork 8
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
14 changed files
with
842 additions
and
42 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
61 changes: 61 additions & 0 deletions
61
...-monitor/src/main/java/org/apache/linkis/monitor/scan/app/bml/cleaner/dao/VersionDao.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,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); | ||
} |
209 changes: 209 additions & 0 deletions
209
...in/java/org/apache/linkis/monitor/scan/app/bml/cleaner/entity/CleanedResourceVersion.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,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; | ||
} | ||
} |
Oops, something went wrong.