2521: Explore the possibility to port the StatMan interface onto Dataminer

https://support.d4science.org/issues/2521

Added Resubmit

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128516 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-05-06 16:26:00 +00:00
parent 08931aed39
commit d7682b795c
11 changed files with 393549 additions and 562397 deletions

View File

@ -31,7 +31,6 @@ import org.gcube.portlets.user.dataminermanager.shared.workspace.DataMinerWorkAr
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
@ -73,6 +72,7 @@ public class DataMinerManagerController {
CheckSession.showLogoutDialog();
}
/*
private void sessionExpiredShowDelayed() {
Timer timeoutTimer = new Timer() {
public void run() {
@ -84,36 +84,7 @@ public class DataMinerManagerController {
timeoutTimer.schedule(TIMEOUT * 1000); // timeout is in milliseconds
}
private void callHello() {
DataMinerPortletServiceAsync.INSTANCE
.hello(new AsyncCallback<UserInfo>() {
@Override
public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed();
} else {
UtilsGXT3.alert(
"Error",
"No user found: "
+ caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(UserInfo result) {
userInfo = result;
Log.info("Hello: " + userInfo.getUsername());
retrieveDataMinerWorkArea();
}
});
}
}*/
private void bind() {
@ -213,15 +184,34 @@ public class DataMinerManagerController {
});
/*
* EventBusProvider.INSTANCE.addHandler(
* ResubmitComputationEvent.getType(), new
* ResubmitComputationEvent.ResubmitComputationHandler() {
*
* @Override public void onResubmitComputation( ResubmitComputationEvent
* event) { switchTo(experimentPanel);
* header.setMenuSelected(MenuItem.EXPERIMENT); } });
*/
}
private void callHello() {
DataMinerPortletServiceAsync.INSTANCE
.hello(new AsyncCallback<UserInfo>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session!");
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
UtilsGXT3.alert(
"Error",
"No user found: "
+ caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(UserInfo result) {
userInfo = result;
Log.info("Hello: " + userInfo.getUsername());
retrieveDataMinerWorkArea();
}
});
}
@ -261,11 +251,17 @@ public class DataMinerManagerController {
@Override
public void onFailure(Throwable caught) {
UtilsGXT3.alert("Error",
"Failed to start computation "
+ event.getOp().getName() + "! "
+ caught.getLocalizedMessage());
caught.printStackTrace();
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session!");
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
UtilsGXT3.alert("Error",
"Failed to start computation "
+ event.getOp().getName() + "! "
+ caught.getLocalizedMessage());
caught.printStackTrace();
}
}
});
@ -288,15 +284,13 @@ public class DataMinerManagerController {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session");
UtilsGXT3.alert("Error", "Expired Session!");
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
UtilsGXT3.alert(
"Error",
"Error in cancel computation: ComputationId="
+ computationId.getId()
+ ", Error="
UtilsGXT3.alert("Error",
"Error in cancel computation "
+ computationId.getId() + ": "
+ caught.getLocalizedMessage());
}
@ -313,19 +307,20 @@ public class DataMinerManagerController {
private void resubmitComputationRequest(
final ResubmitComputationExecutionRequestEvent event) {
DataMinerPortletServiceAsync.INSTANCE.resubmit(
event.getComputationId(), new AsyncCallback<ComputationId>() {
event.getItemDescription(), new AsyncCallback<ComputationId>() {
@Override
public void onFailure(Throwable caught) {
UtilsGXT3
.alert("Error",
"Failed to resubmit computation "
+ event.getComputationId()
+ "<br/>Cause:"
+ caught.getCause()
+ "<br/>Message:"
+ caught.getMessage());
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session!");
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
UtilsGXT3.alert(
"Error",
"Failed to resubmit computation: "
+ caught.getMessage());
}
}
@Override
@ -387,12 +382,18 @@ public class DataMinerManagerController {
@Override
public void onFailure(Throwable caught) {
UtilsGXT3.alert("Error",
"Error retrieving operators classification! "
+ caught.getLocalizedMessage());
Log.error("Error retrieving operators classification: "
+ caught.getLocalizedMessage());
caught.printStackTrace();
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session");
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
UtilsGXT3.alert("Error",
"Error retrieving operators classification! "
+ caught.getLocalizedMessage());
Log.error("Error retrieving operators classification: "
+ caught.getLocalizedMessage());
caught.printStackTrace();
}
}
});
}
@ -440,10 +441,10 @@ public class DataMinerManagerController {
@Override
public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed();
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
UtilsGXT3.alert("Error",
"Error retrieving DataMiner work area info: "
@ -475,10 +476,10 @@ public class DataMinerManagerController {
@Override
public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed();
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
UtilsGXT3.alert("Error",
"Error deleting item on workspace: "

View File

@ -9,6 +9,7 @@ import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.DeleteItemRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.RefreshDataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.SessionExpiredEvent;
import org.gcube.portlets.user.dataminermanager.client.events.UIStateEvent;
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
@ -450,7 +451,18 @@ public class ComputationsPanel extends FramedPanel {
}
private void resubmitComputation() {
// TODO Auto-generated method stub
if (selectedItem != null) {
ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem
.getType().name());
ResubmitComputationExecutionRequestEvent resubmitComputationEvent = new ResubmitComputationExecutionRequestEvent(
itemDescription);
EventBusProvider.INSTANCE.fireEvent(resubmitComputationEvent);
Log.debug("Fired: " + resubmitComputationEvent);
} else {
UtilsGXT3.info("Attention", "Select a computation!");
}
}

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.workspace.ItemDescription;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
@ -20,7 +20,7 @@ public class ResubmitComputationExecutionRequestEvent
GwtEvent<ResubmitComputationExecutionRequestEvent.ResubmitComputationExecutionRequestEventHandler> {
public static Type<ResubmitComputationExecutionRequestEventHandler> TYPE = new Type<ResubmitComputationExecutionRequestEventHandler>();
private ComputationId computationId;
private ItemDescription itemDescription;
public interface ResubmitComputationExecutionRequestEventHandler extends
EventHandler {
@ -33,12 +33,14 @@ public class ResubmitComputationExecutionRequestEvent
ResubmitComputationExecutionRequestEventHandler handler);
}
public ResubmitComputationExecutionRequestEvent(ComputationId computationId) {
this.computationId = computationId;
public ResubmitComputationExecutionRequestEvent(
ItemDescription itemDescription) {
this.itemDescription = itemDescription;
}
@Override
protected void dispatch(ResubmitComputationExecutionRequestEventHandler handler) {
protected void dispatch(
ResubmitComputationExecutionRequestEventHandler handler) {
handler.onResubmit(this);
}
@ -56,15 +58,14 @@ public class ResubmitComputationExecutionRequestEvent
source.fireEvent(event);
}
public ComputationId getComputationId() {
return computationId;
public ItemDescription getItemDescription() {
return itemDescription;
}
@Override
public String toString() {
return "ResubmitComputationExecutionRequestEvent [computationId="
+ computationId + "]";
return "ResubmitComputationExecutionRequestEvent [itemDescription="
+ itemDescription + "]";
}
}

View File

@ -37,7 +37,7 @@ public interface DataMinerPortletService extends RemoteService {
throws ServiceException;
public ComputationId resubmit(ComputationId computationId) throws ServiceException;
public ComputationId resubmit(ItemDescription itemDescription) throws ServiceException;
public TableItemSimple retrieveTableInformation(Item item)

View File

@ -42,7 +42,7 @@ public interface DataMinerPortletServiceAsync {
void getComputationStatus(ComputationId computationId,
AsyncCallback<ComputationStatus> asyncCallback);
void resubmit(ComputationId computationId,
void resubmit(ItemDescription itemDescription,
AsyncCallback<ComputationId> callback);
void retrieveTableInformation(Item item,

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.dataminermanager.server;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
@ -146,15 +147,17 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
}
@Override
public ComputationId resubmit(ComputationId computationId)
public ComputationId resubmit(ItemDescription itemDescription)
throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
logger.debug("Resubmit(): " + computationId);
logger.debug("Resubmit(): " + itemDescription);
Map<String, String> properties = StorageUtil.getProperties(
aslSession.getUsername(), itemDescription.getId());
logger.debug(properties.toString());
SClient smClient = SessionUtil.getSClient(session, aslSession);
return smClient.resubmitComputation(computationId);
return smClient.resubmitComputation(properties);
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
throw e;

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.dataminermanager.server.smservice;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus;
import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
@ -42,7 +43,7 @@ public abstract class SClient {
throws Exception;
public abstract ComputationId resubmitComputation(
ComputationId computationId) throws Exception;
Map<String, String> computationProperties) throws Exception;
@Override
public String toString() {

View File

@ -277,8 +277,8 @@ public class SClient4WPS extends SClient {
try {
processDescription = wpsClient.getProcessDescription(
wpsProcessingServlet, processId);
} catch (Exception e) {
logger.debug("Retrying with WPS URL: "
} catch (Throwable e) {
logger.error("Error getProcessDescription for process "+processId+" with WPS URL: "
+ wpsProcessingServlet);
if (k == 3)
throw e;
@ -294,7 +294,7 @@ public class SClient4WPS extends SClient {
processDescription.set(XmlString.Factory
.parse(processDescriptionURL));
logger.debug(processDescription.toString());
logger.debug("ProcessDescription: "+processDescription);
InputDescriptionType[] inputList = processDescription
.getDataInputs().getInputArray();
@ -1143,10 +1143,57 @@ public class SClient4WPS extends SClient {
}
@Override
public ComputationId resubmitComputation(ComputationId computationId)
public ComputationId resubmitComputation(Map<String,String> computationProperties)
throws Exception {
// TODO
return null;
ProcessInformations processInformations;
try {
processInformations = describeProcess(computationProperties.get("operator_name"));
} catch (Throwable e) {
logger.error("GetParameters: " + e.getLocalizedMessage());
e.printStackTrace();
throw new Exception(e.getLocalizedMessage(), e);
}
LinkedHashMap<String, Parameter> inputParameters = new LinkedHashMap<>();
Parameter inputParameter;
for (InputDescriptionType inputDesc : processInformations.getInputs()) {
inputParameter = WPS2SM.convert2SMType(inputDesc);
logger.debug("InputParameter: " + inputParameter);
inputParameters.put(inputParameter.getName(), inputParameter);
}
Map<String, String> userInputs = new LinkedHashMap<>();
for(Map.Entry<String, String> entry:computationProperties.entrySet()){
if(entry.getKey().startsWith("input")){
int inputSeparatorIndex=entry.getKey().indexOf("_");
String inputKey=entry.getKey().substring(inputSeparatorIndex+1);
userInputs.put(inputKey, entry.getValue());
logger.debug("UserInputs[key=" + inputKey + ", value="
+ entry.getValue() + "]");
}
}
String processUrl = compute(processInformations, userInputs,
inputParameters);
logger.debug("Stated Computation ProcessLocation:" + processUrl);
int idIndex = processUrl.lastIndexOf("?id=");
String id;
if (idIndex > -1) {
id = processUrl.substring(idIndex + 4, processUrl.length());
} else {
logger.error("Invalid processLocation: " + processUrl);
throw new Exception("Invalid processLocation: " + processUrl);
}
ComputationId computationId = new ComputationId(id, processUrl);
logger.debug("ComputationId: " + computationId);
runningProcess.put(computationId, processInformations);
return computationId;
}
}

View File

@ -7,24 +7,19 @@ import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.gcube.common.homelibrary.home.Home;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Properties;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeException;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnection;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
@ -32,6 +27,12 @@ import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class StorageUtil {
private static Logger logger = Logger.getLogger(StorageUtil.class);
@ -76,50 +77,55 @@ public class StorageUtil {
}
public static String extractLocation(String url) {
String[] loc = url.split("//");
// logger.trace("url extracted: " + loc[1]);
return loc[1];
}
public static String getFileName(String url) {
String[] urlParam = url.split("\\?");
String location = extractLocation(urlParam[0]);
/**
*
* @param user
* @param itemId
* @return
* @throws ServiceException
*/
public static Map<String, String> getProperties(String user,
String itemId) throws ServiceException {
try {
return location.split("/")[1];
} catch (Exception e) {
// e.printStackTrace();
return location;
Workspace ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(itemId);
Properties properties = workSpaceItem.getProperties();
return properties.getProperties();
} catch (WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | ItemNotFoundException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
* @return
*
* public static Map<String, String> getFilesUrlFromFolderUrl(
* String serviceClass, String serviceName, String url, String
* username, String scope) throws Exception {
*
* Home home = HomeLibrary.getHomeManagerFactory().getHomeManager()
* .getHome(username); Map<String, String> map = new
* LinkedHashMap<String, String>(); Workspace ws =
* home.getWorkspace(); WorkspaceItem folderItem =
* ws.getItemByPath(url); //
* logger.trace("Type of workspace item is : " // +
* folderItem.getType().toString()); WorkspaceFolder folder =
* (WorkspaceFolder) folderItem; List<WorkspaceItem> childrenList =
* folder.getChildren(); for (WorkspaceItem item : childrenList) {
* ExternalImage file = (ExternalImage) item; String name =
* item.getName(); String absoluteUrlFile = file.getPublicLink();
*
* map.put(name, absoluteUrlFile); }
*
* return map; }
*/
public static Map<String, String> getFilesUrlFromFolderUrl(
String serviceClass, String serviceName, String url,
String username, String scope) throws Exception {
Home home = HomeLibrary.getHomeManagerFactory().getHomeManager()
.getHome(username);
Map<String, String> map = new LinkedHashMap<String, String>();
Workspace ws = home.getWorkspace();
WorkspaceItem folderItem = ws.getItemByPath(url);
// logger.trace("Type of workspace item is : "
// + folderItem.getType().toString());
WorkspaceFolder folder = (WorkspaceFolder) folderItem;
List<WorkspaceItem> childrenList = folder.getChildren();
for (WorkspaceItem item : childrenList) {
ExternalImage file = (ExternalImage) item;
String name = item.getName();
String absoluteUrlFile = file.getPublicLink();
map.put(name, absoluteUrlFile);
}
return map;
}
/**
*
@ -145,6 +151,7 @@ public class StorageUtil {
} catch (WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | ItemNotFoundException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
@ -159,7 +166,7 @@ public class StorageUtil {
* @return InputStream
* @throws StatAlgoImporterServiceException
*/
public static InputStream getImputStream(String user, WorkspaceItem wi)
private static InputStream getImputStream(String user, WorkspaceItem wi)
throws ServiceException {
InputStream is = null;
try {
@ -169,7 +176,7 @@ public class StorageUtil {
return is;
} catch (Throwable e) {
logger.error("Error retrieving file from storage", e);
logger.error("Error retrieving InputStream from storage", e);
e.printStackTrace();
throw new ServiceException("Error retrieving file from storage: "
+ e.getLocalizedMessage(), e);
@ -201,6 +208,8 @@ public class StorageUtil {
} catch (WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | ItemNotFoundException e) {
logger.error("Error retrieving public link: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
@ -284,22 +293,22 @@ public class StorageUtil {
}
public static String saveOnStorageInTemporalFile(InputStream is)
throws ServiceException {
try {
logger.debug("SaveOnStorageInTemporalFile()");
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd_HHmmss");
Double v=Math.random()*10000;
String tempFile = "P_"+sdf.format(new Date())+"_"+ v.intValue()+".xml";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
Double v = Math.random() * 10000;
String tempFile = "P_" + sdf.format(new Date()) + "_"
+ v.intValue() + ".xml";
String remotePath = "/DataMiner/AlgoritmsParameters/" + tempFile;
IClient client = new StorageClient("DataAnalysis", "DataMiner",
"DataMiner", AccessType.PUBLIC, MemoryType.VOLATILE)
.getClient();
String storageId=client.put(true).LFile(is).RFile(remotePath);
logger.debug("Storage id: "+storageId);
String storageId = client.put(true).LFile(is).RFile(remotePath);
logger.debug("Storage id: " + storageId);
String publicLink = client.getHttpUrl().RFile(remotePath);
logger.debug("Storage public link: "+publicLink);
logger.debug("Storage public link: " + publicLink);
return publicLink;
} catch (Throwable e) {

540783
test.log.1

File diff suppressed because one or more lines are too long

414795
test.log.2

File diff suppressed because one or more lines are too long