Updated OperationMonitor
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-monitor-widget@99251 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
80b1f97e7d
commit
b0b60bb661
|
@ -89,6 +89,7 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
||||||
|
|
||||||
progressUpdater.addListener(this);
|
progressUpdater.addListener(this);
|
||||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||||
|
progressUpdater.
|
||||||
show();
|
show();
|
||||||
ok.setVisible(false);
|
ok.setVisible(false);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
||||||
|
|
||||||
public MonitorUpdater(OperationMonitorSession operationMonitorSession){
|
public MonitorUpdater(OperationMonitorSession operationMonitorSession){
|
||||||
this.operationMonitorSession=operationMonitorSession;
|
this.operationMonitorSession=operationMonitorSession;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,34 +40,41 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
cancel();
|
cancel();
|
||||||
|
|
||||||
Log.error("Error retrieving the operation state",
|
Log.error("Error retrieving the operation state",
|
||||||
caught);
|
caught);
|
||||||
String message = getStack(caught);
|
String message = getStack(caught);
|
||||||
fireOperationFailed(caught,
|
fireMonitorFailed(caught,
|
||||||
"Failed getting operation updates", message);
|
"Failed getting operation updates", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSuccess(OperationMonitor result) {
|
public void onSuccess(OperationMonitor result) {
|
||||||
Log.info("retrieved OperationMonitor: "
|
Log.info("retrieved OperationMonitor: "
|
||||||
+ result.getTask().getState());
|
+ result.getTask().getState());
|
||||||
|
|
||||||
|
if(result.isAbort()){
|
||||||
|
cancel();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
switch (result.getTask().getState()) {
|
switch (result.getTask().getState()) {
|
||||||
case INITIALIZING:
|
case INITIALIZING:
|
||||||
Log.info("Initializing...");
|
Log.info("Initializing...");
|
||||||
fireOperationInitializing();
|
fireMonitorInitializing();
|
||||||
break;
|
break;
|
||||||
case ABORTED:
|
case ABORTED:
|
||||||
cancel();
|
cancel();
|
||||||
Log.info("Aborted");
|
Log.info("Aborted");
|
||||||
break;
|
break;
|
||||||
case IN_PROGRESS:
|
case IN_PROGRESS:
|
||||||
fireOperationUpdate(result.getTask().getProgress());
|
fireMonitorUpdate(result.getTask().getProgress());
|
||||||
break;
|
break;
|
||||||
case VALIDATING_RULES:
|
case VALIDATING_RULES:
|
||||||
fireOperationValidate(result.getTask().getProgress());
|
fireMonitorValidate(result.getTask().getProgress());
|
||||||
break;
|
break;
|
||||||
case GENERATING_VIEW:
|
case GENERATING_VIEW:
|
||||||
Log.info("Generating View...");
|
Log.info("Generating View...");
|
||||||
fireOperationGeneratingView();
|
fireMonitorGeneratingView();
|
||||||
break;
|
break;
|
||||||
case STOPPED:
|
case STOPPED:
|
||||||
cancel();
|
cancel();
|
||||||
|
@ -80,7 +88,7 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
||||||
cancel();
|
cancel();
|
||||||
Log.info("Fisnish :"
|
Log.info("Fisnish :"
|
||||||
+ result.getTrId());
|
+ result.getTrId());
|
||||||
fireOperationComplete(result.getTrId());
|
fireMonitorComplete(result.getTrId());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.info("Unknow State");
|
Log.info("Unknow State");
|
||||||
|
@ -98,34 +106,34 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
||||||
protected void errorMessage(OperationMonitor result) {
|
protected void errorMessage(OperationMonitor result) {
|
||||||
Log.info("Opration Failed");
|
Log.info("Opration Failed");
|
||||||
Throwable th;
|
Throwable th;
|
||||||
String failure = null;
|
String reason = null;
|
||||||
String details = null;
|
String details = null;
|
||||||
if (result.getTask().getErrorCause() != null) {
|
if (result.getTask().getErrorCause() != null) {
|
||||||
th = result.getTask().getErrorCause();
|
th = result.getTask().getErrorCause();
|
||||||
failure = "Failed Client Library";
|
reason = "Failed Client Library";
|
||||||
details = result.getTask().getErrorCause().getLocalizedMessage();
|
details = result.getTask().getErrorCause().getLocalizedMessage();
|
||||||
} else {
|
} else {
|
||||||
th = new Throwable("Failed");
|
th = new Throwable("Operation failed");
|
||||||
failure = "Failed Client Library";
|
reason = "Failed Client Library";
|
||||||
details = "Operation failed";
|
details = "Operation failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
fireOperationFailed(th, failure, details);
|
fireMonitorFailed(th, reason, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void stopMessage(OperationMonitor result) {
|
protected void stopMessage(OperationMonitor result) {
|
||||||
Log.info("Operation Stopped");
|
Log.info("Operation Stopped");
|
||||||
String failure = null;
|
String reason = null;
|
||||||
String details = null;
|
String details = null;
|
||||||
if (result.getTask().getErrorCause() != null) {
|
if (result.getTask().getErrorCause() != null) {
|
||||||
failure = "Stopped Operation";
|
reason = "Stopped Operation";
|
||||||
details = result.getTask().getErrorCause().getLocalizedMessage();
|
details = result.getTask().getErrorCause().getLocalizedMessage();
|
||||||
} else {
|
} else {
|
||||||
failure = "Stopped Operation";
|
reason = "Stopped Operation";
|
||||||
details = "Operation stopped";
|
details = "Operation stopped";
|
||||||
}
|
}
|
||||||
|
|
||||||
fireOperationStopped(result.getTrId(),failure, details);
|
fireMonitorStopped(result.getTrId(),reason, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,38 +145,38 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationInitializing() {
|
protected void fireMonitorInitializing() {
|
||||||
for (MonitorUpdaterListener listener : listeners)
|
for (MonitorUpdaterListener listener : listeners)
|
||||||
listener.monitorInitializing();
|
listener.monitorInitializing();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationGeneratingView() {
|
protected void fireMonitorGeneratingView() {
|
||||||
for (MonitorUpdaterListener listener : listeners)
|
for (MonitorUpdaterListener listener : listeners)
|
||||||
listener.monitorGeneratingView();
|
listener.monitorGeneratingView();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationUpdate(float elaborated) {
|
protected void fireMonitorUpdate(float elaborated) {
|
||||||
for (MonitorUpdaterListener listener : listeners)
|
for (MonitorUpdaterListener listener : listeners)
|
||||||
listener.monitorUpdate(elaborated);
|
listener.monitorUpdate(elaborated);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationValidate(float elaborated) {
|
protected void fireMonitorValidate(float elaborated) {
|
||||||
for (MonitorUpdaterListener listener : listeners)
|
for (MonitorUpdaterListener listener : listeners)
|
||||||
listener.monitorValidate(elaborated);
|
listener.monitorValidate(elaborated);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationComplete(TRId trId) {
|
protected void fireMonitorComplete(TRId trId) {
|
||||||
for (MonitorUpdaterListener listener : listeners)
|
for (MonitorUpdaterListener listener : listeners)
|
||||||
listener.monitorComplete(trId);
|
listener.monitorComplete(trId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationFailed(Throwable caught, String failure,
|
protected void fireMonitorFailed(Throwable caught, String failure,
|
||||||
String failureDetails) {
|
String failureDetails) {
|
||||||
for (MonitorUpdaterListener listener : listeners)
|
for (MonitorUpdaterListener listener : listeners)
|
||||||
listener.monitorFailed(caught, failure, failureDetails);
|
listener.monitorFailed(caught, failure, failureDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
protected void fireMonitorStopped(TRId trId, String reason, String details) {
|
||||||
for (MonitorUpdaterListener listener : listeners)
|
for (MonitorUpdaterListener listener : listeners)
|
||||||
listener.monitorStopped(trId,reason, details);
|
listener.monitorStopped(trId,reason, details);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue