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:
parent
75083534f8
commit
ce01864bf9
|
@ -13,7 +13,7 @@
|
|||
<environment name="maxBackups" value="10" type="java.lang.String"
|
||||
override="false" />
|
||||
|
||||
<environment name="scheduledBackupInHours" value="24"
|
||||
<environment name="scheduledBackupInHours" value="2"
|
||||
type="java.lang.String" override="false" />
|
||||
|
||||
<environment name="sweeperIntervalinMillis" value="120000"
|
||||
|
|
|
@ -28,6 +28,14 @@
|
|||
|
||||
<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 -->
|
||||
<xsd:element name="XMLStorageNotAvailableFaultType">
|
||||
<xsd:complexType>
|
||||
|
@ -59,6 +67,26 @@
|
|||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="ShutdownFailedFaultType">
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="corefaults:GCUBERetrySameFault">
|
||||
<xsd:sequence/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</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>
|
||||
|
||||
|
||||
|
@ -85,6 +113,22 @@
|
|||
<part name="parameters" element="tns:VoidRestoreResponse"/>
|
||||
</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">
|
||||
<part name="fault" element="tns:XMLStorageNotAvailableFaultType"/>
|
||||
</wsdl:message>
|
||||
|
@ -93,10 +137,18 @@
|
|||
<part name="fault" element="tns:BackupFailedFaultType"/>
|
||||
</wsdl:message>
|
||||
|
||||
<wsdl:message name="ShutdownFailedFaultTypeMessage">
|
||||
<part name="fault" element="tns:ShutdownFailedFaultType"/>
|
||||
</wsdl:message>
|
||||
|
||||
<wsdl:message name="BackupNotAvailableFaultTypeMessage">
|
||||
<part name="fault" element="tns:BackupNotAvailableFaultType"/>
|
||||
</wsdl:message>
|
||||
|
||||
<wsdl:message name="AlreadyConnectedFaultTypeMessage">
|
||||
<part name="fault" element="tns:AlreadyConnectedFaultType"/>
|
||||
</wsdl:message>
|
||||
|
||||
<!--============================================================
|
||||
|
||||
P O R T T Y P E
|
||||
|
@ -120,19 +172,22 @@
|
|||
<wsdl:fault name="fault2" message="tns:BackupNotAvailableFaultTypeMessage"/>
|
||||
</wsdl:operation>
|
||||
|
||||
<!--
|
||||
<wsdl:operation name="Shutdown">
|
||||
<wsdl:input message="tns:ShutdownInputMessage"/>
|
||||
<wsdl:output message="tns:ShutdownOutputMessage"/>
|
||||
<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 name="Restart">
|
||||
<wsdl:input message="tns:RestartInputMessage"/>
|
||||
<wsdl:output message="tns:RestartOutputMessage"/>
|
||||
|
||||
<wsdl:operation name="Connect">
|
||||
<wsdl:input message="tns:ConnectInputMessage"/>
|
||||
<wsdl:output message="tns:ConnectOutputMessage"/>
|
||||
<wsdl:fault name="fault" message="tns:XMLStorageNotAvailableFaultTypeMessage"/>
|
||||
<wsdl:fault name="fault2" message="tns:AlreadyConnectedFaultTypeMessage"/>
|
||||
</wsdl:operation>
|
||||
-->
|
||||
|
||||
</wsdl:portType>
|
||||
|
||||
</wsdl:definitions>
|
|
@ -402,7 +402,7 @@ public class AggregatorPersistentResource extends PersistentResource {
|
|||
* @return the lastUpdateTime in milliseconds
|
||||
* @throws Exception if an error occurs when accessing the LastUpdateMs field
|
||||
*/
|
||||
public long getLastUpdateTimeinMills() throws Exception {
|
||||
public long getLastUpdateTimeinMills() throws MalformedResourceException {
|
||||
|
||||
if (lastUpdateTime != null)
|
||||
return lastUpdateTime.getTimeInMillis();
|
||||
|
@ -414,18 +414,18 @@ public class AggregatorPersistentResource extends PersistentResource {
|
|||
} catch (XPathExpressionException xpee) {
|
||||
logger.error("" + xpee.getMessage());
|
||||
logger.error("" + xpee.getStackTrace());
|
||||
throw new Exception("XPath evaluation error");
|
||||
throw new MalformedResourceException("XPath evaluation error");
|
||||
}
|
||||
try {
|
||||
return Long.parseLong(value);
|
||||
} catch (NumberFormatException nfe) {
|
||||
logger.error("Invalid last update time format found in resource " + this.getID());
|
||||
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
|
||||
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
|
||||
*
|
||||
*/
|
||||
private void parseResource() throws Exception {
|
||||
private void parseResource() throws MalformedResourceException {
|
||||
logger.debug("Parsing resource: " + this.resource_string);
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
StringReader reader = new StringReader(this.resource_string);
|
||||
InputSource source = new InputSource(reader);
|
||||
this.internalDOM = builder.parse(source);
|
||||
try {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
StringReader reader = new StringReader(this.resource_string);
|
||||
InputSource source = new InputSource(reader);
|
||||
this.internalDOM = builder.parse(source);
|
||||
} catch (Exception e) {
|
||||
throw new MalformedResourceException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public abstract class PersistentResource {
|
|||
* if the resource has no profile type (i.e. it is not a
|
||||
* profile)
|
||||
*/
|
||||
public abstract String getProfileType() throws Exception;
|
||||
public abstract String getProfileType() throws MalformedResourceException;
|
||||
|
||||
/**
|
||||
* Gets the publisher of the resource
|
||||
|
@ -62,7 +62,7 @@ public abstract class PersistentResource {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract long getLastUpdateTimeinMills() throws Exception;
|
||||
public abstract long getLastUpdateTimeinMills() throws MalformedResourceException;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -94,5 +94,16 @@ public abstract class PersistentResource {
|
|||
return false;
|
||||
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);}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,15 @@ package org.gcube.informationsystem.collector.impl.porttypes;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.oasis.wsrf.faults.BaseFaultType;
|
||||
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.BackupNotAvailableFaultType;
|
||||
import org.gcube.informationsystem.collector.stubs.ShutdownFailedFaultType;
|
||||
import org.gcube.informationsystem.collector.stubs.XMLStorageNotAvailableFaultType;
|
||||
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.types.VOID;
|
||||
import org.gcube.informationsystem.collector.impl.contexts.ICServiceContext;
|
||||
|
@ -50,6 +52,13 @@ public class XMLStorageAccess extends GCUBEPortType {
|
|||
return new VOID();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BackupNotAvailableFaultType
|
||||
* @throws XMLStorageNotAvailableFaultType
|
||||
*/
|
||||
public VOID restore(VOID params) throws BackupNotAvailableFaultType, XMLStorageNotAvailableFaultType {
|
||||
|
||||
try {
|
||||
|
@ -62,39 +71,68 @@ public class XMLStorageAccess extends GCUBEPortType {
|
|||
}
|
||||
|
||||
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
|
||||
this.backup(new VOID());
|
||||
/*try {
|
||||
logger.info("Dispose operation invoked");
|
||||
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");
|
||||
logger.info("Connect operation invoked");
|
||||
try {
|
||||
State.initialize();
|
||||
ICServiceContext.getContext().setStatus(Status.READIED);
|
||||
} catch (Exception e) {
|
||||
logger.error("unable to pose the IC with success ", e);
|
||||
BaseFaultType fault = new BaseFaultType();
|
||||
FaultHelper faultHelper = new FaultHelper(fault);
|
||||
faultHelper.addFaultCause(e);
|
||||
faultHelper
|
||||
.addDescription("-IC service: Unable to pose the service");
|
||||
logger.error("Initialisation failed", e);
|
||||
XMLStorageNotAvailableFaultType fault = new XMLStorageNotAvailableFaultType();
|
||||
fault.addFaultDetailString("Initialisation failed," + e.getMessage());
|
||||
throw fault;
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
return new VOID();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public class DataManager extends XMLStorageManager {
|
|||
|
||||
try {
|
||||
ExistBackupFolder lastBackup = this.getLastBackup();
|
||||
logger.info("Restoring from " + lastBackup.getBackupFile());
|
||||
Restore restore = new Restore("admin", "admin","admin", lastBackup.getBackupFile(), URI);
|
||||
restore.restore(false, null);
|
||||
logger.info("Restore completed");
|
||||
|
|
|
@ -91,14 +91,6 @@ public class State {
|
|||
queryManager.initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the container base dir
|
||||
*/
|
||||
// public static String getBaseDirectory() {
|
||||
// return ContainerConfig.getBaseDirectory();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Releases all the State resources
|
||||
*
|
||||
|
|
|
@ -61,6 +61,7 @@ public class Sweeper implements Runnable {
|
|||
this.cleanExpiredResources();
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
logger.error("Unable to sleep (yawn)", ie);
|
||||
// thread was interrupted
|
||||
storage.shutdown();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.exist.storage.DBBroker;
|
|||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.informationsystem.collector.impl.persistence.AggregatorPersistentResource;
|
||||
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.xmlstorage.exist.XMLStorageManager;
|
||||
import org.gcube.informationsystem.collector.impl.xmlstorage.exist.XQuery;
|
||||
|
@ -62,6 +63,10 @@ public class XMLStorageManager {
|
|||
|
||||
protected static String PROFILES_COLLECTION_NAME = "Profiles";
|
||||
|
||||
enum STATUS {INITIALISED, CLOSED, SHUTDOWN};
|
||||
|
||||
protected static STATUS status = STATUS.CLOSED;
|
||||
|
||||
/**
|
||||
* Creates a new manager
|
||||
*
|
||||
|
@ -77,9 +82,14 @@ public class XMLStorageManager {
|
|||
* @throws Exception
|
||||
* 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 {
|
||||
logger.info("connecting to eXist DB...");
|
||||
logger.info("Initializing XMLStorage...");
|
||||
// this.printEnv();
|
||||
|
||||
// lock the instance
|
||||
|
@ -96,7 +106,7 @@ public class XMLStorageManager {
|
|||
this.rootCollection = DatabaseManager.getCollection(URI + DBBroker.ROOT_COLLECTION, "admin", "admin");
|
||||
if (this.rootCollection == null) {
|
||||
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");
|
||||
this.profilesRootCollection = this.rootCollection.getChildCollection(XMLStorageManager.PROFILES_COLLECTION_NAME);
|
||||
|
@ -106,21 +116,22 @@ public class XMLStorageManager {
|
|||
logger.debug("Profiles collection created");
|
||||
}
|
||||
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("encoding", "UTF-8");
|
||||
this.profilesRootCollection.setProperty("pretty", "true");
|
||||
this.profilesRootCollection.setProperty("encoding", "UTF-8");
|
||||
status= STATUS.INITIALISED;
|
||||
} catch (XMLDBException 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) {
|
||||
logger.debug("unable to initialize XML storage ", e);
|
||||
throw new Exception("unable to initialize XML storage");
|
||||
logger.error("unable to initialize XML storage ", e);
|
||||
throw new XMLStorageNotAvailableException("unable to initialize XML storage");
|
||||
} catch (java.lang.NoClassDefFoundError ncdfe) {
|
||||
logger.debug("unable to initialize XML storage", ncdfe);
|
||||
throw new Exception("unable to initialize XML storage");
|
||||
logger.error("unable to initialize XML storage", ncdfe);
|
||||
throw new XMLStorageNotAvailableException("unable to initialize XML storage");
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
}
|
||||
|
@ -137,6 +148,7 @@ public class XMLStorageManager {
|
|||
try {
|
||||
DatabaseInstanceManager manager = (DatabaseInstanceManager) rootCollection.getService("DatabaseInstanceManager", "1.0");
|
||||
manager.shutdown();
|
||||
status = STATUS.SHUTDOWN;
|
||||
} catch (XMLDBException edb) {
|
||||
logger.error("Unable to shutdown XML storage");
|
||||
logger.error("" + edb.getCause());
|
||||
|
@ -257,8 +269,10 @@ public class XMLStorageManager {
|
|||
* @throws Exception
|
||||
* 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;
|
||||
if (resource.getType() == RESOURCETYPE.Profile) {
|
||||
// the entry contains a gCube resource profile
|
||||
|
@ -270,7 +284,7 @@ public class XMLStorageManager {
|
|||
|
||||
if (currentCollection == null) {
|
||||
logger.error("Unable to open the Collection");
|
||||
return;
|
||||
throw new XMLStorageNotAvailableException("Unable to open the Collection");
|
||||
}
|
||||
writeLock.lock();
|
||||
this.locked = true;
|
||||
|
@ -626,4 +640,16 @@ public class XMLStorageManager {
|
|||
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);}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class BackupTester {
|
|||
port = new XMLStorageAccessServiceLocator().getXMLStorageAccessPortTypePort(new URL(portTypeURI));
|
||||
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope("/CNRPrivate"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("",e);
|
||||
}
|
||||
|
||||
logger.info("Submitting backup request...");
|
||||
|
|
|
@ -46,7 +46,7 @@ public class RestoreTester {
|
|||
port = new XMLStorageAccessServiceLocator().getXMLStorageAccessPortTypePort(new URL(portTypeURI));
|
||||
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope("/CNRPrivate"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("",e);
|
||||
}
|
||||
|
||||
logger.info("Submitting restore request...");
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
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!!
|
||||
*
|
||||
|
@ -8,11 +21,47 @@ package org.gcube.informationsystem.collector.stubs.testsuite;
|
|||
*/
|
||||
public class ShutdownTester {
|
||||
|
||||
private static GCUBEClientLog logger = new GCUBEClientLog(RestoreTester.class);
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* <ol>
|
||||
* <li>IC host
|
||||
* <li>IC port
|
||||
* <li>Caller Scope
|
||||
* </ol>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class XQueryExecuteTester {
|
|||
port = new XQueryAccessServiceLocator().getXQueryAccessPortTypePort(new URL(portTypeURI));
|
||||
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope(args[2]));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("",e);
|
||||
}
|
||||
|
||||
XQueryExecuteRequest request = new XQueryExecuteRequest();
|
||||
|
|
Loading…
Reference in New Issue