use of com.alibaba.otter.shared.arbitrate.exception.ArbitrateException in project otter by alibaba.
the class ArbitrateFactory method newInstance.
// ==================== helper method =======================
private static Object newInstance(Class type, Long pipelineId) {
Constructor _constructor = null;
Object[] _constructorArgs = new Object[1];
_constructorArgs[0] = pipelineId;
try {
_constructor = type.getConstructor(new Class[] { Long.class });
} catch (NoSuchMethodException e) {
throw new ArbitrateException("Constructor_notFound");
}
try {
return _constructor.newInstance(_constructorArgs);
} catch (Exception e) {
throw new ArbitrateException("Constructor_newInstance_error", e);
}
}
use of com.alibaba.otter.shared.arbitrate.exception.ArbitrateException in project otter by alibaba.
the class ToolArbitrateEvent method fetch.
/**
* 提供数据接口获取对应pipeline上的状态
*/
public SyncStatusEventData fetch(Long pipelineId) {
String path = StagePathUtils.getPipeline(pipelineId);
try {
byte[] bytes = zookeeper.readData(path);
if (bytes == null || bytes.length == 0) {
SyncStatusEventData evnetData = new SyncStatusEventData();
evnetData.setPipelineId(pipelineId);
return evnetData;
} else {
return JsonUtils.unmarshalFromByte(bytes, SyncStatusEventData.class);
}
} catch (ZkException e) {
// 没有节点返回空
throw new ArbitrateException("fetch_SyncStatus", pipelineId.toString(), e);
}
}
use of com.alibaba.otter.shared.arbitrate.exception.ArbitrateException in project otter by alibaba.
the class ToolArbitrateEvent method single.
/**
* 提供数据接口更新对应的pipeline上的状态
*/
public void single(SyncStatusEventData syncStatus) {
String path = StagePathUtils.getPipeline(syncStatus.getPipelineId());
try {
byte[] bytes = JsonUtils.marshalToByte(syncStatus);
zookeeper.writeData(path, bytes);
logger.info("## single status : " + syncStatus);
} catch (ZkException e) {
throw new ArbitrateException("single_SyncStatus", syncStatus.getPipelineId().toString(), e);
}
}
use of com.alibaba.otter.shared.arbitrate.exception.ArbitrateException in project otter by alibaba.
the class MainStemMonitorTest method switchWarmup.
/**
* 手工触发一次主备切换
*/
private void switchWarmup(Long channelId, Long pipelineId) {
String path = ManagePathUtils.getMainStem(channelId, pipelineId);
try {
while (true) {
Stat stat = new Stat();
byte[] bytes = zookeeper.readData(path, stat);
MainStemEventData mainStemData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
mainStemData.setActive(false);
try {
zookeeper.writeData(path, JsonUtils.marshalToByte(mainStemData), stat.getVersion());
break;
} catch (ZkBadVersionException e) {
// ignore , retrying
}
}
} catch (ZkNoNodeException e) {
// ignore
} catch (ZkException e) {
throw new ArbitrateException("releaseMainStem", pipelineId.toString(), e);
}
}
Aggregations