address feedback
Original commit: elastic/x-pack-elasticsearch@7f7f2c0e1f
This commit is contained in:
parent
8e0f5f905e
commit
8285fbdd46
|
@ -270,15 +270,19 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
|
|||
client.admin().cluster().prepareState().execute(new ActionListener<ClusterStateResponse>() {
|
||||
@Override
|
||||
public void onResponse(ClusterStateResponse clusterStateResponse) {
|
||||
if (canStart(clusterStateResponse.getState(), master)) {
|
||||
if (master) {
|
||||
final boolean currentMaster = clusterService.state().getNodes().isLocalNodeElectedMaster();
|
||||
if (canStart(clusterStateResponse.getState(), currentMaster)) {
|
||||
if (currentMaster) {
|
||||
putTemplate(customAuditIndexSettings(settings), ActionListener.wrap((v) -> innerStart(),
|
||||
(e) -> state.set(State.FAILED)));
|
||||
} else {
|
||||
innerStart();
|
||||
}
|
||||
} else {
|
||||
state.compareAndSet(State.STARTING, State.INITIALIZED);
|
||||
if (state.compareAndSet(State.STARTING, State.INITIALIZED) == false) {
|
||||
throw new IllegalStateException("state transition from starting to initialized failed, current value: " +
|
||||
state.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,8 +291,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
|
|||
logger.error("failed to get remote cluster state", e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (master) {
|
||||
} else if (master) {
|
||||
putTemplate(customAuditIndexSettings(settings), ActionListener.wrap((v) -> innerStart(),
|
||||
(e) -> state.set(State.FAILED)));
|
||||
} else {
|
||||
|
@ -296,7 +299,6 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void innerStart() {
|
||||
if (indexToRemoteCluster == false) {
|
||||
|
|
Loading…
Reference in New Issue