use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook in project ovirt-engine by oVirt.
the class ClusterGlusterHookListModel method onResolveConflicts.
/*
* If there are multiple types of conflicts found for a hook and the user choose to resolve them. The conflicts will
* be resolved in the following order 1)Content Conflict, 2)Status Conflict, 3)Missing Conflict
*
* If any conflict resolution is failed the next one will not be executed
*/
private void onResolveConflicts() {
final GlusterHookResolveConflictsModel resolveConflictsModel = (GlusterHookResolveConflictsModel) getWindow();
if (resolveConflictsModel == null) {
return;
}
if (!resolveConflictsModel.isAnyResolveActionSelected()) {
resolveConflictsModel.setMessage(ConstantsManager.getInstance().getConstants().noResolveActionSelectedGlusterHook());
return;
}
resolveConflictsModel.startProgress();
GlusterHookEntity hookEntity = resolveConflictsModel.getGlusterHookEntity();
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
if (resolveConflictsModel.getResolveContentConflict().getEntity()) {
actionTypes.add(ActionType.UpdateGlusterHook);
GlusterServerHook serverHook = resolveConflictsModel.getServerHooksList().getSelectedItem();
Guid serverId = (serverHook == null) ? null : serverHook.getServerId();
parameters.add(new GlusterHookManageParameters(hookEntity.getId(), serverId));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveContentConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveContentConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
if (resolveConflictsModel.getResolveStatusConflict().getEntity()) {
boolean isEnable = resolveConflictsModel.getResolveStatusConflictEnable().getEntity();
actionTypes.add(isEnable ? ActionType.EnableGlusterHook : ActionType.DisableGlusterHook);
parameters.add(new GlusterHookParameters(hookEntity.getId()));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveStatusConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveStatusConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
if (resolveConflictsModel.getResolveMissingConflict().getEntity()) {
boolean isAdd = resolveConflictsModel.getResolveMissingConflictCopy().getEntity();
actionTypes.add(isAdd ? ActionType.AddGlusterHook : ActionType.RemoveGlusterHook);
parameters.add(new GlusterHookManageParameters(hookEntity.getId()));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveMissingConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveMissingConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
IFrontendActionAsyncCallback onFinishCallback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.stopProgress();
cancel();
syncSearch();
}
};
IFrontendActionAsyncCallback failureCallback = result -> resolveConflictsModel.stopProgress();
// Replacing the last callback with onFinishCallback, as we just want to close the dialog and execute the search
if (callbacks.size() > 0) {
callbacks.remove(callbacks.size() - 1);
callbacks.add(onFinishCallback);
Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, failureCallback, null);
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook in project ovirt-engine by oVirt.
the class GlusterHookResolveConflictsModel method onSelectedHookSourceChanged.
private void onSelectedHookSourceChanged() {
EntityModel<GlusterServerHook> selectedItem = getHookSources().getSelectedItem();
if (selectedItem == null) {
return;
}
GlusterServerHook selectedServer = selectedItem.getEntity();
getServerHooksList().setSelectedItem(selectedServer);
if (selectedServer.getStatus() == GlusterHookStatus.MISSING) {
getContentModel().getContent().setEntity(null);
getContentModel().getStatus().setEntity(null);
getContentModel().getMd5Checksum().setEntity(null);
return;
}
getContentModel().getStatus().setEntity(selectedServer.getStatus());
getContentModel().getMd5Checksum().setEntity(selectedServer.getChecksum());
if (selectedServer.getContentType() == GlusterHookContentType.TEXT) {
startProgress();
AsyncDataProvider.getInstance().getGlusterHookContent(new AsyncQuery<>(content -> {
getContentModel().getContent().setEntity(content);
stopProgress();
}), getGlusterHookEntity().getId(), selectedServer.getServerId());
} else {
getContentModel().getContent().setEntity(null);
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook in project ovirt-engine by oVirt.
the class GlusterHookMapper method map.
@Mapping(from = GlusterHookEntity.class, to = GlusterHook.class)
public static GlusterHook map(GlusterHookEntity entity, GlusterHook hook) {
GlusterHook model = hook != null ? hook : new GlusterHook();
if (entity.getId() != null) {
model.setId(entity.getId().toString());
}
if (entity.getClusterId() != null) {
model.setCluster(new Cluster());
model.getCluster().setId(entity.getClusterId().toString());
}
if (entity.getHookKey() != null) {
model.setName(entity.getHookKey());
}
if (entity.getGlusterCommand() != null) {
model.setGlusterCommand(entity.getGlusterCommand());
}
if (entity.getStage() != null) {
model.setStage(map(entity.getStage(), null));
}
if (entity.getStatus() != null) {
model.setStatus(mapHookStatus(entity.getStatus()));
}
if (entity.getContentType() != null) {
model.setContentType(map(entity.getContentType(), null));
}
if (entity.getChecksum() != null) {
model.setChecksum(entity.getChecksum());
}
if (entity.getContent() != null) {
model.setContent(entity.getContent());
}
if (entity.getConflictStatus() != null) {
model.setConflictStatus(entity.getConflictStatus());
model.setConflicts(mapConflicts(entity));
}
if (entity.getServerHooks() != null && !entity.getServerHooks().isEmpty()) {
model.setServerHooks(new GlusterServerHooks());
for (GlusterServerHook serverHookEntity : entity.getServerHooks()) {
model.getServerHooks().getGlusterServerHooks().add(map(serverHookEntity));
}
}
return model;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook in project ovirt-engine by oVirt.
the class UpdateGlusterHookCommand method validate.
@Override
protected boolean validate() {
if (!super.validate()) {
return false;
}
if (getContentConflictServerHooks().isEmpty()) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_GLUSTER_HOOK_NO_CONFLICT_SERVERS);
return false;
}
for (GlusterServerHook serverHook : getContentConflictServerHooks()) {
VDS vds = vdsDao.get(serverHook.getServerId());
if (vds == null || vds.getStatus() != VDSStatus.Up) {
String vdsName = vds != null ? vds.getName() : GlusterConstants.NO_SERVER;
setVdsName(vdsName);
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_SERVER_STATUS_NOT_UP);
addValidationMessage(String.format("$%1$s %2$s", "VdsName", vdsName));
return false;
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook in project ovirt-engine by oVirt.
the class AddGlusterHookCommandTest method getHookEntityWithMissing.
private GlusterHookEntity getHookEntityWithMissing() {
GlusterHookEntity hook = getHookEntity();
List<GlusterServerHook> serverHooks = new ArrayList<>();
serverHooks.add(getGlusterServerHook(0, GlusterHookStatus.MISSING));
serverHooks.add(getGlusterServerHook(1, GlusterHookStatus.MISSING));
serverHooks.add(getGlusterServerHook(2, GlusterHookStatus.MISSING));
hook.setServerHooks(serverHooks);
return hook;
}
Aggregations