Merge pull request #2986 from alibaba/hotfix_job_execute_condition

[#2985] fix task executable judgment logic problems
This commit is contained in:
liaochuntao 2020-06-08 00:55:10 +08:00 committed by GitHub
commit 99539dd330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -160,6 +160,9 @@ public class EmbeddedDumpService extends DumpService {
@Override
protected boolean canExecute() {
if (ApplicationUtils.getStandaloneMode()) {
return true;
}
// if is derby + raft mode, only leader can execute
CPProtocol protocol = protocolManager.getCpProtocol();
return protocol.isLeader(Constants.CONFIG_MODEL_RAFT_GROUP);

View File

@ -109,15 +109,11 @@ public class MergeDatumService {
if (!PropertyUtil.isEmbeddedStorage()) {
return true;
}
try {
ProtocolManager protocolManager = ApplicationUtils.getBean(ProtocolManager.class);
return protocolManager.getCpProtocol().isLeader(Constants.CONFIG_MODEL_RAFT_GROUP);
} catch (NoSuchRaftGroupException e) {
if (ApplicationUtils.getStandaloneMode()) {
return true;
} catch (Exception e) {
// It's impossible to get to this point
throw new RuntimeException(e);
}
ProtocolManager protocolManager = ApplicationUtils.getBean(ProtocolManager.class);
return protocolManager.getCpProtocol().isLeader(Constants.CONFIG_MODEL_RAFT_GROUP);
}
class MergeAllDataWorker extends Thread {