mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
update guava to 18.0, magriate compute map by package level implement
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.otter.canal.parse.inbound.mysql.dbsync;
|
||||
|
||||
import com.google.common.collect.MigrateMap;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -38,17 +39,23 @@ public class TableMetaCache {
|
||||
|
||||
public TableMetaCache(MysqlConnection con){
|
||||
this.connection = con;
|
||||
tableMetaCache = new MapMaker().makeComputingMap(new Function<String, TableMeta>() {
|
||||
tableMetaCache = MigrateMap.makeComputingMap(new Function<String, TableMeta>()
|
||||
{
|
||||
|
||||
public TableMeta apply(String name) {
|
||||
try {
|
||||
public TableMeta apply(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return getTableMeta0(name);
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e)
|
||||
{
|
||||
// 尝试做一次retry操作
|
||||
try {
|
||||
try
|
||||
{
|
||||
connection.reconnect();
|
||||
return getTableMeta0(name);
|
||||
} catch (IOException e1) {
|
||||
} catch (IOException e1)
|
||||
{
|
||||
throw new CanalParseException("fetch failed by table meta:" + name, e1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.otter.canal.parse.index;
|
||||
|
||||
import com.google.common.collect.MigrateMap;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -67,21 +68,27 @@ public class FileMixedLogPositionManager extends MemoryLogPositionManager {
|
||||
throw new CanalMetaManagerException("dir[" + dataDir.getPath() + "] can not read/write");
|
||||
}
|
||||
|
||||
dataFileCaches = new MapMaker().makeComputingMap(new Function<String, File>() {
|
||||
dataFileCaches = MigrateMap.makeComputingMap(new Function<String, File>()
|
||||
{
|
||||
|
||||
public File apply(String destination) {
|
||||
public File apply(String destination)
|
||||
{
|
||||
return getDataFile(destination);
|
||||
}
|
||||
});
|
||||
|
||||
executor = Executors.newScheduledThreadPool(1);
|
||||
positions = new MapMaker().makeComputingMap(new Function<String, LogPosition>() {
|
||||
positions = MigrateMap.makeComputingMap(new Function<String, LogPosition>()
|
||||
{
|
||||
|
||||
public LogPosition apply(String destination) {
|
||||
public LogPosition apply(String destination)
|
||||
{
|
||||
LogPosition logPosition = loadDataFromFile(dataFileCaches.get(destination));
|
||||
if (logPosition == null) {
|
||||
if (logPosition == null)
|
||||
{
|
||||
return nullPosition;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return logPosition;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.otter.canal.parse.index;
|
||||
|
||||
import com.google.common.collect.MigrateMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@@ -34,13 +35,17 @@ public class MixedLogPositionManager extends MemoryLogPositionManager implements
|
||||
zooKeeperLogPositionManager.start();
|
||||
}
|
||||
executor = Executors.newFixedThreadPool(1);
|
||||
positions = new MapMaker().makeComputingMap(new Function<String, LogPosition>() {
|
||||
positions = MigrateMap.makeComputingMap(new Function<String, LogPosition>()
|
||||
{
|
||||
|
||||
public LogPosition apply(String destination) {
|
||||
public LogPosition apply(String destination)
|
||||
{
|
||||
LogPosition logPosition = zooKeeperLogPositionManager.getLatestIndexBy(destination);
|
||||
if (logPosition == null) {
|
||||
if (logPosition == null)
|
||||
{
|
||||
return nullPosition;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return logPosition;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.otter.canal.parse.index;
|
||||
|
||||
import com.google.common.collect.MigrateMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -43,13 +44,17 @@ public class PeriodMixedLogPositionManager extends MemoryLogPositionManager impl
|
||||
zooKeeperLogPositionManager.start();
|
||||
}
|
||||
executor = Executors.newScheduledThreadPool(1);
|
||||
positions = new MapMaker().makeComputingMap(new Function<String, LogPosition>() {
|
||||
positions = MigrateMap.makeComputingMap(new Function<String, LogPosition>()
|
||||
{
|
||||
|
||||
public LogPosition apply(String destination) {
|
||||
public LogPosition apply(String destination)
|
||||
{
|
||||
LogPosition logPosition = zooKeeperLogPositionManager.getLatestIndexBy(destination);
|
||||
if (logPosition == null) {
|
||||
if (logPosition == null)
|
||||
{
|
||||
return nullPosition;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return logPosition;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user