zhangzengfei
2020-03-31 0ce893695d32ab686f9e2309509e80c6feb0d380
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.basic.security.manager.erlang;
 
import com.basic.security.utils.Constants;
import com.ericsson.otp.erlang.OtpConnection;
 
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
 
public class ErBaseManger {
 
    public static OtpConnection otpConnection;
 
    public static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor
            (1, 2, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(50),
                    //2.加上调用线程任务本身去run
                    new ThreadPoolExecutor.CallerRunsPolicy()
            );
 
    /**
     * 数据的同步
     *
     * @param sql1
     * @return
     */
    public static boolean executeSqlInCluster(String sql1) {
//        if (1 == 1){
//            return true;
//        }
        if (Constants.syncToErlang) {
            threadPoolExecutor.execute(new Runnable() {
                public void run() {
                    SqliteManager.executeInCache(ErlangConnection.getLocalConnection(), sql1);
                }
            });
        }
        return true;
    }
 
}