From a78b76b664830a1ac691396d5cb64166c6919ff1 Mon Sep 17 00:00:00 2001 From: shikeying <shikeying@163.com> Date: 星期五, 30 九月 2022 18:12:44 +0800 Subject: [PATCH] 视频相似度分析5 --- recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-) diff --git a/recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java b/recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java index 15886e7..2735f65 100644 --- a/recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java +++ b/recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java @@ -1,17 +1,74 @@ package com.iplatform.recvideo.scheduler; +import com.iplatform.core.BeanContextAware; +import com.iplatform.recvideo.VideoLoader; import com.iplatform.recvideo.VideoScheduler; +import com.iplatform.recvideo.service.VideoLoaderServiceImpl; +import com.iplatform.recvideo.support.DefaultVideoLoader; +import com.walker.connector.Address; +import com.walker.connector.support.DatabaseConnector; +import com.walker.connector.util.ConnectorUtils; import com.walker.store.AbstractStore; import com.walker.store.task.GatherTask; +/** + * 鐭棰戦噰闆�(鍔犺浇鎷疯礉)璋冨害浠诲姟瀹炵幇銆� + * @author 鏃跺厠鑻� + * @date 2022-09-30 + */ public class VideoLoadScheduler extends VideoScheduler { + + private VideoLoader videoLoader= null; + private int failedCount = 0; + + private Address srcAddress; // 浠庝笟鍔$郴缁熸暟鎹簱鍔犺浇瑙嗛闆嗗悎璁板綍 public VideoLoadScheduler(int id, String name){ super(id, name); + srcAddress = new Address(); + srcAddress.setUrl("127.0.0.1"); + srcAddress.setPort(3306); + srcAddress.setAuthentication("root"); + srcAddress.setCertification("123456"); } @Override protected GatherTask providerTask(AbstractStore store) { return null; } + + @Override + protected Object onProcess(Object[] inputParams) throws Exception { + if(this.videoLoader == null){ + DefaultVideoLoader defaultVideoLoader = new DefaultVideoLoader(); + defaultVideoLoader.setVideoLoaderService(BeanContextAware.getBeanByType(VideoLoaderServiceImpl.class)); + defaultVideoLoader.setDatabaseConnector(this.createMySqlConnector(this.srcAddress)); + defaultVideoLoader.startup(false); + this.videoLoader = defaultVideoLoader; + logger.debug("鍒涘缓'DefaultVideoLoader': " + defaultVideoLoader.getClass()); + } + + try{ + int result = this.videoLoader.execute(); + if(result == 1){ + logger.info("鎴愬姛鎵ц涓�娆$煭瑙嗛閲囬泦"); + return SUCCESS; + } + logger.debug("videoLoader.execute() = -1锛岀嚎绋嬪噯澶囦紤鐪�"); + return null; + }catch (Exception ex){ + logger.error("VideoLoader.execute()鎶ラ敊: " + ex.getMessage(), ex); + this.failedCount ++; + if(this.failedCount > 3){ + // 濡傛灉鎶ラ敊瓒呰繃澶氭锛岃繑鍥炵┖锛岃绾跨▼浼戠湢涓�涓� + this.failedCount = 0; + } + return null; + } + } + + private DatabaseConnector createMySqlConnector(Address address){ + DatabaseConnector connector = ConnectorUtils.createMySQLConnector(address); + return connector; + } } -- Gitblit v1.9.1