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;
|
}
|
|
}
|