Adding Shutdown and Connect operation, more accurate exception handling

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Collector@14752 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2009-08-27 02:18:28 +00:00
parent 75083534f8
commit ce01864bf9
13 changed files with 248 additions and 71 deletions

View File

@ -13,7 +13,7 @@
<environment name="maxBackups" value="10" type="java.lang.String" <environment name="maxBackups" value="10" type="java.lang.String"
override="false" /> override="false" />
<environment name="scheduledBackupInHours" value="24" <environment name="scheduledBackupInHours" value="2"
type="java.lang.String" override="false" /> type="java.lang.String" override="false" />
<environment name="sweeperIntervalinMillis" value="120000" <environment name="sweeperIntervalinMillis" value="120000"

View File

@ -28,6 +28,14 @@
<xsd:element name="VoidRestoreResponse" type="coretypes:VOID"/> <xsd:element name="VoidRestoreResponse" type="coretypes:VOID"/>
<xsd:element name="VoidShutdownRequest" type="coretypes:VOID"/>
<xsd:element name="VoidShutdownResponse" type="coretypes:VOID"/>
<xsd:element name="VoidConnectRequest" type="coretypes:VOID"/>
<xsd:element name="VoidConnectResponse" type="coretypes:VOID"/>
<!-- FAULTS --> <!-- FAULTS -->
<xsd:element name="XMLStorageNotAvailableFaultType"> <xsd:element name="XMLStorageNotAvailableFaultType">
<xsd:complexType> <xsd:complexType>
@ -51,6 +59,16 @@
<xsd:element name="BackupFailedFaultType"> <xsd:element name="BackupFailedFaultType">
<xsd:complexType> <xsd:complexType>
<xsd:complexContent>
<xsd:extension base="corefaults:GCUBERetrySameFault">
<xsd:sequence/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="ShutdownFailedFaultType">
<xsd:complexType>
<xsd:complexContent> <xsd:complexContent>
<xsd:extension base="corefaults:GCUBERetrySameFault"> <xsd:extension base="corefaults:GCUBERetrySameFault">
<xsd:sequence/> <xsd:sequence/>
@ -59,6 +77,16 @@
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="AlreadyConnectedFaultType">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="corefaults:GCUBERetrySameFault">
<xsd:sequence/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema> </xsd:schema>
@ -85,6 +113,22 @@
<part name="parameters" element="tns:VoidRestoreResponse"/> <part name="parameters" element="tns:VoidRestoreResponse"/>
</wsdl:message> </wsdl:message>
<wsdl:message name="ShutdownInputMessage">
<part name="parameters" element="tns:VoidShutdownRequest"/>
</wsdl:message>
<wsdl:message name="ShutdownOutputMessage">
<part name="parameters" element="tns:VoidShutdownResponse"/>
</wsdl:message>
<wsdl:message name="ConnectInputMessage">
<part name="parameters" element="tns:VoidConnectRequest"/>
</wsdl:message>
<wsdl:message name="ConnectOutputMessage">
<part name="parameters" element="tns:VoidConnectResponse"/>
</wsdl:message>
<wsdl:message name="XMLStorageNotAvailableFaultTypeMessage"> <wsdl:message name="XMLStorageNotAvailableFaultTypeMessage">
<part name="fault" element="tns:XMLStorageNotAvailableFaultType"/> <part name="fault" element="tns:XMLStorageNotAvailableFaultType"/>
</wsdl:message> </wsdl:message>
@ -93,9 +137,17 @@
<part name="fault" element="tns:BackupFailedFaultType"/> <part name="fault" element="tns:BackupFailedFaultType"/>
</wsdl:message> </wsdl:message>
<wsdl:message name="ShutdownFailedFaultTypeMessage">
<part name="fault" element="tns:ShutdownFailedFaultType"/>
</wsdl:message>
<wsdl:message name="BackupNotAvailableFaultTypeMessage"> <wsdl:message name="BackupNotAvailableFaultTypeMessage">
<part name="fault" element="tns:BackupNotAvailableFaultType"/> <part name="fault" element="tns:BackupNotAvailableFaultType"/>
</wsdl:message> </wsdl:message>
<wsdl:message name="AlreadyConnectedFaultTypeMessage">
<part name="fault" element="tns:AlreadyConnectedFaultType"/>
</wsdl:message>
<!--============================================================ <!--============================================================
@ -118,21 +170,24 @@
<wsdl:output message="tns:RestoreOutputMessage"/> <wsdl:output message="tns:RestoreOutputMessage"/>
<wsdl:fault name="fault" message="tns:XMLStorageNotAvailableFaultTypeMessage"/> <wsdl:fault name="fault" message="tns:XMLStorageNotAvailableFaultTypeMessage"/>
<wsdl:fault name="fault2" message="tns:BackupNotAvailableFaultTypeMessage"/> <wsdl:fault name="fault2" message="tns:BackupNotAvailableFaultTypeMessage"/>
</wsdl:operation> </wsdl:operation>
<!--
<wsdl:operation name="Shutdown"> <wsdl:operation name="Shutdown">
<wsdl:input message="tns:ShutdownInputMessage"/> <wsdl:input message="tns:ShutdownInputMessage"/>
<wsdl:output message="tns:ShutdownOutputMessage"/> <wsdl:output message="tns:ShutdownOutputMessage"/>
<wsdl:fault name="fault" message="tns:XMLStorageNotAvailableFaultTypeMessage"/> <wsdl:fault name="fault" message="tns:XMLStorageNotAvailableFaultTypeMessage"/>
<wsdl:fault name="fault2" message="tns:BackupFailedFaultTypeMessage"/>
<wsdl:fault name="fault3" message="tns:ShutdownFailedFaultTypeMessage"/>
</wsdl:operation> </wsdl:operation>
<wsdl:operation name="Restart">
<wsdl:input message="tns:RestartInputMessage"/> <wsdl:operation name="Connect">
<wsdl:output message="tns:RestartOutputMessage"/> <wsdl:input message="tns:ConnectInputMessage"/>
<wsdl:output message="tns:ConnectOutputMessage"/>
<wsdl:fault name="fault" message="tns:XMLStorageNotAvailableFaultTypeMessage"/> <wsdl:fault name="fault" message="tns:XMLStorageNotAvailableFaultTypeMessage"/>
<wsdl:fault name="fault2" message="tns:AlreadyConnectedFaultTypeMessage"/>
</wsdl:operation> </wsdl:operation>
-->
</wsdl:portType> </wsdl:portType>
</wsdl:definitions> </wsdl:definitions>

View File

@ -402,7 +402,7 @@ public class AggregatorPersistentResource extends PersistentResource {
* @return the lastUpdateTime in milliseconds * @return the lastUpdateTime in milliseconds
* @throws Exception if an error occurs when accessing the LastUpdateMs field * @throws Exception if an error occurs when accessing the LastUpdateMs field
*/ */
public long getLastUpdateTimeinMills() throws Exception { public long getLastUpdateTimeinMills() throws MalformedResourceException {
if (lastUpdateTime != null) if (lastUpdateTime != null)
return lastUpdateTime.getTimeInMillis(); return lastUpdateTime.getTimeInMillis();
@ -414,18 +414,18 @@ public class AggregatorPersistentResource extends PersistentResource {
} catch (XPathExpressionException xpee) { } catch (XPathExpressionException xpee) {
logger.error("" + xpee.getMessage()); logger.error("" + xpee.getMessage());
logger.error("" + xpee.getStackTrace()); logger.error("" + xpee.getStackTrace());
throw new Exception("XPath evaluation error"); throw new MalformedResourceException("XPath evaluation error");
} }
try { try {
return Long.parseLong(value); return Long.parseLong(value);
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
logger.error("Invalid last update time format found in resource " + this.getID()); logger.error("Invalid last update time format found in resource " + this.getID());
logger.error("Parsed string was " + value); logger.error("Parsed string was " + value);
throw new Exception("Unable to retrieve last update time for resource " + this.getID()); throw new MalformedResourceException("Unable to retrieve last update time for resource " + this.getID());
} }
} else } else
throw new Exception("unable to retrieve last update time for resource " + this.getID()); throw new MalformedResourceException("unable to retrieve last update time for resource " + this.getID());
} }
@ -433,13 +433,17 @@ public class AggregatorPersistentResource extends PersistentResource {
* Loads the XML DOM from the resource string * Loads the XML DOM from the resource string
* *
*/ */
private void parseResource() throws Exception { private void parseResource() throws MalformedResourceException {
logger.debug("Parsing resource: " + this.resource_string); logger.debug("Parsing resource: " + this.resource_string);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try {
DocumentBuilder builder = factory.newDocumentBuilder(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
StringReader reader = new StringReader(this.resource_string); DocumentBuilder builder = factory.newDocumentBuilder();
InputSource source = new InputSource(reader); StringReader reader = new StringReader(this.resource_string);
this.internalDOM = builder.parse(source); InputSource source = new InputSource(reader);
this.internalDOM = builder.parse(source);
} catch (Exception e) {
throw new MalformedResourceException(e);
}
} }

View File

@ -41,7 +41,7 @@ public abstract class PersistentResource {
* if the resource has no profile type (i.e. it is not a * if the resource has no profile type (i.e. it is not a
* profile) * profile)
*/ */
public abstract String getProfileType() throws Exception; public abstract String getProfileType() throws MalformedResourceException;
/** /**
* Gets the publisher of the resource * Gets the publisher of the resource
@ -62,7 +62,7 @@ public abstract class PersistentResource {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public abstract long getLastUpdateTimeinMills() throws Exception; public abstract long getLastUpdateTimeinMills() throws MalformedResourceException;
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -94,5 +94,16 @@ public abstract class PersistentResource {
return false; return false;
return true; return true;
} }
/**
*
* Malformed resource exception
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public static class MalformedResourceException extends Exception {
private static final long serialVersionUID = 1L;
public MalformedResourceException(Exception e) {super(e);}
public MalformedResourceException(String message) {super(message);}
}
} }

View File

@ -2,13 +2,15 @@ package org.gcube.informationsystem.collector.impl.porttypes;
import java.io.IOException; import java.io.IOException;
import org.oasis.wsrf.faults.BaseFaultType;
import org.xmldb.api.base.XMLDBException; import org.xmldb.api.base.XMLDBException;
import org.gcube.informationsystem.collector.stubs.AlreadyConnectedFaultType;
import org.gcube.informationsystem.collector.stubs.BackupFailedFaultType; import org.gcube.informationsystem.collector.stubs.BackupFailedFaultType;
import org.gcube.informationsystem.collector.stubs.BackupNotAvailableFaultType; import org.gcube.informationsystem.collector.stubs.BackupNotAvailableFaultType;
import org.gcube.informationsystem.collector.stubs.ShutdownFailedFaultType;
import org.gcube.informationsystem.collector.stubs.XMLStorageNotAvailableFaultType; import org.gcube.informationsystem.collector.stubs.XMLStorageNotAvailableFaultType;
import org.gcube.common.core.contexts.GCUBEServiceContext; import org.gcube.common.core.contexts.GCUBEServiceContext;
import org.gcube.common.core.contexts.GCUBEServiceContext.Status;
import org.gcube.common.core.porttypes.GCUBEPortType; import org.gcube.common.core.porttypes.GCUBEPortType;
import org.gcube.common.core.types.VOID; import org.gcube.common.core.types.VOID;
import org.gcube.informationsystem.collector.impl.contexts.ICServiceContext; import org.gcube.informationsystem.collector.impl.contexts.ICServiceContext;
@ -50,6 +52,13 @@ public class XMLStorageAccess extends GCUBEPortType {
return new VOID(); return new VOID();
} }
/**
*
* @param params
* @return
* @throws BackupNotAvailableFaultType
* @throws XMLStorageNotAvailableFaultType
*/
public VOID restore(VOID params) throws BackupNotAvailableFaultType, XMLStorageNotAvailableFaultType { public VOID restore(VOID params) throws BackupNotAvailableFaultType, XMLStorageNotAvailableFaultType {
try { try {
@ -61,40 +70,69 @@ public class XMLStorageAccess extends GCUBEPortType {
throw fault; throw fault;
} }
return new VOID(); return new VOID();
}
/**
* Shutdowns the XMLStorage
*
* @throws BackupFailedFaultType if the backup before the shutdown fails
* @throws XMLStorageNotAvailableFaultType if the XMLStorage is not available
* @throws ShutdownFailedFaultType if the shutdown fails
*/
public VOID shutdown(VOID params) throws BackupFailedFaultType, XMLStorageNotAvailableFaultType, ShutdownFailedFaultType {
logger.info("Shutdown operation invoked");
//request the backup before to shutdown
try {
State.getDataManager().backup();
} catch (XMLDBException e) {
logger.error("Unable to backup before shutting down" ,e);
XMLStorageNotAvailableFaultType fault = new XMLStorageNotAvailableFaultType();
fault.addFaultDetailString("No valid backup has been found");
throw fault;
} catch (Exception e) {
logger.error("Unable to backup before shutting down" ,e);
//should we throw here and leave?
BackupFailedFaultType fault = new BackupFailedFaultType();
fault.addFaultDetailString("No valid backup has been found");
throw fault;
}
try {
State.dispose();
ICServiceContext.getContext().setStatus(Status.DOWN);
} catch (Exception e) {
logger.error("Shutdown failed", e);
ShutdownFailedFaultType fault = new ShutdownFailedFaultType();
fault.addFaultDetailString("Shutdown failed," + e.getMessage());
throw fault;
}
return new VOID();
} }
/** /**
* Disposes the XMLStorage
* *
* @throws BaseFaultType if the shutdown fails * @param params
* @return
* @throws XMLStorageNotAvailableFaultType
* @throws AlreadyConnectedFaultType
*/ */
public void dispose() throws BaseFaultType { public VOID connect(VOID params) throws XMLStorageNotAvailableFaultType, AlreadyConnectedFaultType {
//request the backup before to shutdown logger.info("Connect operation invoked");
this.backup(new VOID()); try {
/*try { State.initialize();
logger.info("Dispose operation invoked"); ICServiceContext.getContext().setStatus(Status.READIED);
logger.info("trying to shutdown the storage instances...");
try {
State.storage_manager.shutdown();
State.query_manager.shutdown();
} catch (NullPointerException se) {
}
State.storage_manager = null;
State.query_manager = null;
// request the interruption of the sweeper thread
State.sweeperT.interrupt();
logger.info("done");
} catch (Exception e) { } catch (Exception e) {
logger.error("unable to pose the IC with success ", e); logger.error("Initialisation failed", e);
BaseFaultType fault = new BaseFaultType(); XMLStorageNotAvailableFaultType fault = new XMLStorageNotAvailableFaultType();
FaultHelper faultHelper = new FaultHelper(fault); fault.addFaultDetailString("Initialisation failed," + e.getMessage());
faultHelper.addFaultCause(e);
faultHelper
.addDescription("-IC service: Unable to pose the service");
throw fault; throw fault;
} */ }
return new VOID();
} }
} }

View File

@ -76,6 +76,7 @@ public class DataManager extends XMLStorageManager {
try { try {
ExistBackupFolder lastBackup = this.getLastBackup(); ExistBackupFolder lastBackup = this.getLastBackup();
logger.info("Restoring from " + lastBackup.getBackupFile());
Restore restore = new Restore("admin", "admin","admin", lastBackup.getBackupFile(), URI); Restore restore = new Restore("admin", "admin","admin", lastBackup.getBackupFile(), URI);
restore.restore(false, null); restore.restore(false, null);
logger.info("Restore completed"); logger.info("Restore completed");

View File

@ -91,14 +91,6 @@ public class State {
queryManager.initialize(); queryManager.initialize();
} }
/**
*
* @return the container base dir
*/
// public static String getBaseDirectory() {
// return ContainerConfig.getBaseDirectory();
// }
/** /**
* Releases all the State resources * Releases all the State resources
* *

View File

@ -61,6 +61,7 @@ public class Sweeper implements Runnable {
this.cleanExpiredResources(); this.cleanExpiredResources();
} }
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
logger.error("Unable to sleep (yawn)", ie);
// thread was interrupted // thread was interrupted
storage.shutdown(); storage.shutdown();
} }

View File

@ -17,6 +17,7 @@ import org.exist.storage.DBBroker;
import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.collector.impl.persistence.AggregatorPersistentResource; import org.gcube.informationsystem.collector.impl.persistence.AggregatorPersistentResource;
import org.gcube.informationsystem.collector.impl.persistence.PersistentResource; import org.gcube.informationsystem.collector.impl.persistence.PersistentResource;
import org.gcube.informationsystem.collector.impl.persistence.PersistentResource.MalformedResourceException;
import org.gcube.informationsystem.collector.impl.persistence.PersistentResource.RESOURCETYPE; import org.gcube.informationsystem.collector.impl.persistence.PersistentResource.RESOURCETYPE;
import org.gcube.informationsystem.collector.impl.xmlstorage.exist.XMLStorageManager; import org.gcube.informationsystem.collector.impl.xmlstorage.exist.XMLStorageManager;
import org.gcube.informationsystem.collector.impl.xmlstorage.exist.XQuery; import org.gcube.informationsystem.collector.impl.xmlstorage.exist.XQuery;
@ -62,6 +63,10 @@ public class XMLStorageManager {
protected static String PROFILES_COLLECTION_NAME = "Profiles"; protected static String PROFILES_COLLECTION_NAME = "Profiles";
enum STATUS {INITIALISED, CLOSED, SHUTDOWN};
protected static STATUS status = STATUS.CLOSED;
/** /**
* Creates a new manager * Creates a new manager
* *
@ -77,9 +82,14 @@ public class XMLStorageManager {
* @throws Exception * @throws Exception
* if the connection to eXist or its initialization fail * if the connection to eXist or its initialization fail
*/ */
public void initialize() throws Exception { public void initialize() throws XMLStorageNotAvailableException {
if (status == STATUS.INITIALISED) {
logger.warn("XMLStorage already initialized");
return;
}
try { try {
logger.info("connecting to eXist DB..."); logger.info("Initializing XMLStorage...");
// this.printEnv(); // this.printEnv();
// lock the instance // lock the instance
@ -96,7 +106,7 @@ public class XMLStorageManager {
this.rootCollection = DatabaseManager.getCollection(URI + DBBroker.ROOT_COLLECTION, "admin", "admin"); this.rootCollection = DatabaseManager.getCollection(URI + DBBroker.ROOT_COLLECTION, "admin", "admin");
if (this.rootCollection == null) { if (this.rootCollection == null) {
logger.error("invalid root collection!"); logger.error("invalid root collection!");
throw new Exception("unable to load root collection"); throw new XMLStorageNotAvailableException("unable to load root collection");
} }
logger.debug("Initializing the collection Profiles"); logger.debug("Initializing the collection Profiles");
this.profilesRootCollection = this.rootCollection.getChildCollection(XMLStorageManager.PROFILES_COLLECTION_NAME); this.profilesRootCollection = this.rootCollection.getChildCollection(XMLStorageManager.PROFILES_COLLECTION_NAME);
@ -106,21 +116,22 @@ public class XMLStorageManager {
logger.debug("Profiles collection created"); logger.debug("Profiles collection created");
} }
if (this.profilesRootCollection == null) { if (this.profilesRootCollection == null) {
throw new Exception("Unable to load/create Profiles collection"); throw new XMLStorageNotAvailableException("Unable to load/create Profiles collection");
} }
this.rootCollection.setProperty("pretty", "true"); this.rootCollection.setProperty("pretty", "true");
this.rootCollection.setProperty("encoding", "UTF-8"); this.rootCollection.setProperty("encoding", "UTF-8");
this.profilesRootCollection.setProperty("pretty", "true"); this.profilesRootCollection.setProperty("pretty", "true");
this.profilesRootCollection.setProperty("encoding", "UTF-8"); this.profilesRootCollection.setProperty("encoding", "UTF-8");
status= STATUS.INITIALISED;
} catch (XMLDBException edb) { } catch (XMLDBException edb) {
logger.error("unable to initialize XML storage ", edb); logger.error("unable to initialize XML storage ", edb);
throw new Exception("unable to initialize XML storage"); throw new XMLStorageNotAvailableException("unable to initialize XML storage");
} catch (Exception e) { } catch (Exception e) {
logger.debug("unable to initialize XML storage ", e); logger.error("unable to initialize XML storage ", e);
throw new Exception("unable to initialize XML storage"); throw new XMLStorageNotAvailableException("unable to initialize XML storage");
} catch (java.lang.NoClassDefFoundError ncdfe) { } catch (java.lang.NoClassDefFoundError ncdfe) {
logger.debug("unable to initialize XML storage", ncdfe); logger.error("unable to initialize XML storage", ncdfe);
throw new Exception("unable to initialize XML storage"); throw new XMLStorageNotAvailableException("unable to initialize XML storage");
} finally { } finally {
writeLock.unlock(); writeLock.unlock();
} }
@ -137,6 +148,7 @@ public class XMLStorageManager {
try { try {
DatabaseInstanceManager manager = (DatabaseInstanceManager) rootCollection.getService("DatabaseInstanceManager", "1.0"); DatabaseInstanceManager manager = (DatabaseInstanceManager) rootCollection.getService("DatabaseInstanceManager", "1.0");
manager.shutdown(); manager.shutdown();
status = STATUS.SHUTDOWN;
} catch (XMLDBException edb) { } catch (XMLDBException edb) {
logger.error("Unable to shutdown XML storage"); logger.error("Unable to shutdown XML storage");
logger.error("" + edb.getCause()); logger.error("" + edb.getCause());
@ -257,8 +269,10 @@ public class XMLStorageManager {
* @throws Exception * @throws Exception
* if the storing fails * if the storing fails
*/ */
public void storeResource(PersistentResource resource) throws Exception { public void storeResource(PersistentResource resource) throws XMLStorageNotAvailableException, MalformedResourceException {
if (status != STATUS.INITIALISED)
throw new XMLStorageNotAvailableException("XMLStorage not initialized");
Collection currentCollection = null; Collection currentCollection = null;
if (resource.getType() == RESOURCETYPE.Profile) { if (resource.getType() == RESOURCETYPE.Profile) {
// the entry contains a gCube resource profile // the entry contains a gCube resource profile
@ -270,7 +284,7 @@ public class XMLStorageManager {
if (currentCollection == null) { if (currentCollection == null) {
logger.error("Unable to open the Collection"); logger.error("Unable to open the Collection");
return; throw new XMLStorageNotAvailableException("Unable to open the Collection");
} }
writeLock.lock(); writeLock.lock();
this.locked = true; this.locked = true;
@ -626,4 +640,16 @@ public class XMLStorageManager {
return content.toString(); return content.toString();
} }
/**
*
* XMLStorage not initialized exception
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public static class XMLStorageNotAvailableException extends Exception {
private static final long serialVersionUID = 1L;
public XMLStorageNotAvailableException(String message) { super(message);}
}
} }

View File

@ -47,7 +47,7 @@ public class BackupTester {
port = new XMLStorageAccessServiceLocator().getXMLStorageAccessPortTypePort(new URL(portTypeURI)); port = new XMLStorageAccessServiceLocator().getXMLStorageAccessPortTypePort(new URL(portTypeURI));
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope("/CNRPrivate")); port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope("/CNRPrivate"));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error("",e);
} }
logger.info("Submitting backup request..."); logger.info("Submitting backup request...");

View File

@ -46,7 +46,7 @@ public class RestoreTester {
port = new XMLStorageAccessServiceLocator().getXMLStorageAccessPortTypePort(new URL(portTypeURI)); port = new XMLStorageAccessServiceLocator().getXMLStorageAccessPortTypePort(new URL(portTypeURI));
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope("/CNRPrivate")); port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope("/CNRPrivate"));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error("",e);
} }
logger.info("Submitting restore request..."); logger.info("Submitting restore request...");

View File

@ -1,18 +1,67 @@
package org.gcube.informationsystem.collector.stubs.testsuite; package org.gcube.informationsystem.collector.stubs.testsuite;
import java.net.URL;
import java.rmi.RemoteException;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.types.VOID;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.informationsystem.collector.stubs.BackupFailedFaultType;
import org.gcube.informationsystem.collector.stubs.ShutdownFailedFaultType;
import org.gcube.informationsystem.collector.stubs.XMLStorageAccessPortType;
import org.gcube.informationsystem.collector.stubs.XMLStorageNotAvailableFaultType;
import org.gcube.informationsystem.collector.stubs.service.XMLStorageAccessServiceLocator;
/** /**
* TODO: Manuele, don't forget to add a comment for this new type!! * TODO: Manuele, don't forget to add a comment for this new type!!
* *
* @author Manuele Simi (ISTI-CNR) * @author Manuele Simi (ISTI-CNR)
* *
*/ */
public class ShutdownTester { public class ShutdownTester {
private static GCUBEClientLog logger = new GCUBEClientLog(RestoreTester.class);
/** /**
* @param args * @param args
* <ol>
* <li>IC host
* <li>IC port
* <li>Caller Scope
* </ol>
*/ */
public static void main(String[] args) { public static void main(String[] args) {
/*
* if (args.length != 3) { logger.fatal("Usage: RestoreTester <host> <port> <Scope>");
* return; }
*/
// final String portTypeURI = "http://" + args[0] + ":" + args[1] +
// "/wsrf/services/gcube/informationsystem/collector/XMLStorageAccess";
final String portTypeURI = "http://node10.d.d4science.research-infrastructures.eu:8080/wsrf/services/gcube/informationsystem/collector/XMLStorageAccess";
XMLStorageAccessPortType port = null;
try {
port = new XMLStorageAccessServiceLocator().getXMLStorageAccessPortTypePort(new URL(portTypeURI));
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope("/CNRPrivate"));
} catch (Exception e) {
logger.error("",e);
}
logger.info("Submitting shutdown request to " + portTypeURI+ "...");
try {
port.shutdown(new VOID());
} catch (XMLStorageNotAvailableFaultType e) {
logger.error("",e);
} catch (ShutdownFailedFaultType e) {
logger.error("",e);
} catch (BackupFailedFaultType e) {
logger.error("",e);
} catch (RemoteException e) {
logger.error("",e);
}
} }

View File

@ -48,7 +48,7 @@ public class XQueryExecuteTester {
port = new XQueryAccessServiceLocator().getXQueryAccessPortTypePort(new URL(portTypeURI)); port = new XQueryAccessServiceLocator().getXQueryAccessPortTypePort(new URL(portTypeURI));
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope(args[2])); port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope(args[2]));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error("",e);
} }
XQueryExecuteRequest request = new XQueryExecuteRequest(); XQueryExecuteRequest request = new XQueryExecuteRequest();