Merge branch 'dev' into docker_package
This commit is contained in:
commit
0d5257c994
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.renren.common.domain.Tsingtao_xhaProperties;
|
||||
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
@ -13,14 +14,22 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* 青岛西海岸
|
||||
*/
|
||||
public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService {
|
||||
private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors();
|
||||
private static Logger logger = LoggerFactory.getLogger(TsingtaoXHAVideoPreviewService.class);
|
||||
Tsingtao_xhaProperties tsingtao_xhaProperties;
|
||||
private static final OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.MINUTES)
|
||||
.connectionPool(new ConnectionPool(cpuNUm * 2, 2, TimeUnit.MINUTES))
|
||||
.retryOnConnectionFailure(false)
|
||||
.build();
|
||||
|
||||
public TsingtaoXHAVideoPreviewService(Tsingtao_xhaProperties tsingtao_xhaProperties) {
|
||||
this.tsingtao_xhaProperties = tsingtao_xhaProperties;
|
||||
|
@ -35,9 +44,8 @@ public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService
|
|||
@Override
|
||||
public String getHls(String key) {
|
||||
List<String> result = new CopyOnWriteArrayList<>();
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder().url(String.format(tsingtao_xhaProperties.getCloudhls(), key)).build();
|
||||
String url = String.format(tsingtao_xhaProperties.getCloudhls(), key);
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (response.isSuccessful()) {
|
||||
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||
|
@ -45,10 +53,10 @@ public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService
|
|||
result.add(jsonObject.getString("data"));
|
||||
}
|
||||
} else {
|
||||
logger.error("西海岸预览地址获取失败");
|
||||
logger.error("西海岸预览地址获取失败:{}", url);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
logger.error("西海岸预览地址获取失败", exception);
|
||||
logger.error("西海岸预览地址获取失败:", url, exception);
|
||||
}
|
||||
return result.stream().filter(index -> StringUtils.isNotEmpty(index)).findAny().orElse(null);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue