use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class PermitMonitorTest method init.
@BeforeClass
public void init() {
// 初始化节点
Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {
@Mock
public Channel getChannel(Long pipelineId) {
Channel channel = new Channel();
channel.setId(channelId);
return channel;
}
@Mock
public Pipeline getOppositePipeline(Long pipelineId) {
Pipeline pipeline = new Pipeline();
pipeline.setId(oppositePipelineId);
return pipeline;
}
});
zookeeper = getZookeeper();
channelEvent = new ChannelArbitrateEvent();
pipelineEvent = new PipelineArbitrateEvent();
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class DbLoadAction method buildContext.
private DbLoadContext buildContext(Identity identity) {
DbLoadContext context = new DbLoadContext();
context.setIdentity(identity);
Channel channel = configClientService.findChannel(identity.getChannelId());
Pipeline pipeline = configClientService.findPipeline(identity.getPipelineId());
context.setChannel(channel);
context.setPipeline(pipeline);
return context;
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class FileLoadAction method buildContext.
private FileLoadContext buildContext(Identity identity) {
FileLoadContext context = new FileLoadContext();
context.setIdentity(identity);
Channel channel = configClientService.findChannel(identity.getChannelId());
Pipeline pipeline = configClientService.findPipeline(identity.getPipelineId());
context.setChannel(channel);
context.setPipeline(pipeline);
return context;
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class AbstractOperationInterceptor method updateMark.
/**
* 更新一下事务标记
*/
private void updateMark(DbLoadContext context, DbDialect dialect, int threadId, String sql, boolean needInfo, String hint) {
Identity identity = context.getIdentity();
Channel channel = context.getChannel();
// 获取dbDialect
String markTableName = context.getPipeline().getParameters().getSystemSchema() + "." + context.getPipeline().getParameters().getSystemMarkTable();
String markTableColumn = context.getPipeline().getParameters().getSystemMarkTableColumn();
synchronized (dialect.getJdbcTemplate()) {
if (tableCheckStatus.contains(dialect.getJdbcTemplate()) == false) {
init(dialect.getJdbcTemplate(), markTableName, markTableColumn);
tableCheckStatus.add(dialect.getJdbcTemplate());
}
}
int affectedCount = 0;
if (needInfo) {
String infoColumn = context.getPipeline().getParameters().getSystemMarkTableInfo();
// 记录一下channelInfo
String info = context.getPipeline().getParameters().getChannelInfo();
String esql = MessageFormat.format(sql, new Object[] { markTableName, markTableColumn, infoColumn });
if (hint != null) {
esql = hint + esql;
}
affectedCount = dialect.getJdbcTemplate().update(esql, new Object[] { threadId, channel.getId(), info });
} else {
String esql = MessageFormat.format(sql, new Object[] { markTableName, markTableColumn });
if (hint != null) {
esql = hint + esql;
}
affectedCount = dialect.getJdbcTemplate().update(esql, new Object[] { threadId, channel.getId() });
}
if (affectedCount <= 0) {
logger.warn("## update {} failed by [{}]", markTableName, threadId);
} else {
if (logger.isInfoEnabled()) {
logger.debug("Interceptor For [{}]", identity);
}
}
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class ArbitrateConfigImpl method findOppositePipeline.
public Pipeline findOppositePipeline(Long pipelineId) {
Long channelId = channelMapping.get(pipelineId);
Channel channel = channelCache.get(channelId);
List<Pipeline> pipelines = channel.getPipelines();
for (Pipeline pipeline : pipelines) {
if (pipeline.getId().equals(pipelineId) == false) {
// 这里假定pipeline只有两个
return pipeline;
}
}
return null;
}
Aggregations