public ExecutorService getThreadPool(){ return new ThreadPoolExecutor(75, 125, 180000, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(450), new ThreadPoolExecutor.CallerRunsPolicy()); }
@Service public class InsuranceVerificationServiceImpl implements InsuranceVerificationService { private static final Logger logger = LoggerFactory.getLogger(InsuranceVerificationServiceImpl.class); @Override public TaskResponseModel
核保常规校验服务类:UnderwritingCheckServiceImpl,假设耗时50ms
@Service public class UnderwritingCheckServiceImpl implements UnderwritingCheckService { private static final Logger logger = LoggerFactory.getLogger(UnderwritingCheckServiceImpl.class); @Override public TaskResponseModel
核保外部调用服务类:ExternalCallServiceImpl,假设耗时200ms
@Service public class ExternalCallServiceImpl implements ExternalCallService { private static final Logger logger = LoggerFactory.getLogger(ExternalCallServiceImpl.class); @Override public TaskResponseModel
试算服务类:TrialCalculationServiceImpl,假设耗时50ms
@Service public class TrialCalculationServiceImpl implements TrialCalculationService { private static final Logger logger = LoggerFactory.getLogger(TrialCalculationServiceImpl.class); @Override public TaskResponseModel
@Data @ToString @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode @Accessors(chain = true) public class TaskResponseModel implements Serializable { private String key; //唯一调用标志 private String resultCode; //结果码 private String resultMessage; //结果信息 private T data; //业务处理结果
public static TaskResponseModel
注:
key为这次调用的唯一标识,由调用者传进来
resultCode结果码,200为成功,400表示有异常
resultMessage信息,表示不成功或者异常信息
data业务处理结果,如果成功的话
这些服务类都是单例模式
要使用用CompletionService的话,需要创建实现了Callable接口的线程
投保Callable:
@Data @AllArgsConstructor public class InsuranceVerificationCommand implements Callable> { private String key; private PolicyModel policyModel; private final InsuranceVerificationService insuranceVerificationService; @Override public TaskResponseModel call() throws Exception { return insuranceVerificationService.insuranceCheck(key, policyModel); } }
核保常规校验Callable:
@Data @AllArgsConstructor public class UnderwritingCheckCommand implements Callable> { private String key; private PolicyModel policyModel; private final UnderwritingCheckService underwritingCheckService; @Override public TaskResponseModel call() throws Exception { return underwritingCheckService.underwritingCheck(key, policyModel); } }
核保外部调用Callable:
@Data @AllArgsConstructor public class ExternalCallCommand implements Callable> { private String key; private Insured insured; private final ExternalCallService externalCallService; @Override public TaskResponseModel call() throws Exception { return externalCallService.externalCall(key, insured); } }
试算调用Callable:
@Data @AllArgsConstructor public class TrialCalculationCommand implements Callable> { private String key; private Risk risk; private final TrialCalculationService trialCalculationService; @Override public TaskResponseModel call() throws Exception { return trialCalculationService.trialCalc(key, risk); } }
注:
每一次调用,需要创建这4种Callable
返回统一接口TaskResopnseModel
异步执行的类:TaskExecutor
@Component public class TaskExecutor { private static final Logger logger = LoggerFactory.getLogger(TaskExecutor.class); //线程池 private final ExecutorService executorService;
public TaskExecutor(ExecutorService executorService) { this.executorService = executorService; }
//异步执行,获取所有结果后返回 public List> execute(List>> commands) { //创建异步执行对象 CompletionService> completionService = new ExecutorCompletionService<>(executorService); for (Callable> command : commands) { completionService.submit(command); } //获取所有异步执行线程的结果 int taskCount = commands.size(); List> params = new ArrayList<>(taskCount); try { for (int i = 0; i < taskCount; i++) { Future> future = completionService.take(); params.add(future.get()); } } catch (InterruptedException | ExecutionException e) { //异常处理 params.clear(); params.add(TaskResponseModel.failure().setKey("error").setResultMessage("异步执行线程错误")); } //返回,如果执行中发生error, 则返回相应的key值:error return params; } }
@RestController public class CompletionServiceController { //投保key private static final String INSURANCE_KEY = "insurance_"; //核保key private static final String UNDERWRITING_KEY = "underwriting_"; //外部调用key private static final String EXTERNALCALL_KEY = "externalcall_"; //试算key private static final String TRIA_KEY = "trial_";
private static final Logger logger = LoggerFactory.getLogger(CompletionServiceController.class);
private final ExternalCallService externalCallService; private final InsuranceVerificationService insuranceVerificationService; private final TrialCalculationService trialCalculationService; private final UnderwritingCheckService underwritingCheckService; private final TaskExecutor taskExecutor;
在网上无意中看到淘宝提交的hotspot patch,共四个,有意思,记录一下。
7050685:jsdbproc64.sh has a typo in the package name
7058036:FieldsAllocationStyle=2 does not work in 32-bit VM
7060619:C1 should respect inline and
CREATE TABLE sessions (
id CHAR(32) NOT NULL,
data TEXT,
last_accessed TIMESTAMP NOT NULL,
PRIMARY KEY (id)
);
<?php
/**
* Created by PhpStorm.
* User: michaeldu
* Date
public Vector<CartProduct> delCart(Vector<CartProduct> cart, String id) {
for (int i = 0; i < cart.size(); i++) {
if (cart.get(i).getId().equals(id)) {
cart.remove(i);
问题是首页在火狐、谷歌、所有IE中正常显示,列表页的页面在火狐谷歌中正常,在IE6、7、8中都不中,觉得可能那个地方设置的让IE系列都不认识,仔细查看后发现,列表页中没写HTML模板部分没有添加DTD定义,就是<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3
com.jcraft.jsch.JSchException: Auth cancel
at com.jcraft.jsch.Session.connect(Session.java:460)
at com.jcraft.jsch.Session.connect(Session.java:154)
at cn.vivame.util.ftp.SftpServerAccess.connec
centos p安装
yum -y install tree
mac os安装
brew install tree
首先来看tree的用法
tree 中文解释:tree
功能说明:以树状图列出目录的内容。
语 法:tree [-aACdDfFgilnNpqstux][-I <范本样式>][-P <范本样式
一. 实体类简述
实体类其实就是俗称的POJO,这种类一般不实现特殊框架下的接口,在程序中仅作为数据容器用来持久化存储数据用的
POJO(Plain Old Java Objects)简单的Java对象
它的一般格式就是
public class A{
private String id;
public Str