From d25c648d2b458cd2e7263c46ff0307b351119466 Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Wed, 26 Aug 2009 01:25:38 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Collector@14713 82a268e6-3cf1-43bd-a215-b396298e98cf --- etc/deploy-jndi-config.xml | 6 ++ schema/XMLStorageAccess.wsdl | 54 +++++++++++---- .../impl/contexts/ICServiceContext.java | 2 +- .../impl/porttypes/XMLStorageAccess.java | 28 ++++++-- .../state/AggregatorRegisteredResource.java | 3 +- .../xmlstorage/backup/BackupsRootFolder.java | 22 ++++-- .../impl/xmlstorage/backup/Scheduler.java | 68 +++++++++++-------- .../impl/xmlstorage/exist/DataManager.java | 42 ++++++++++-- .../xmlstorage/exist/ExistBackupFolder.java | 16 +++-- .../impl/xmlstorage/exist/ExistScheduler.java | 17 +++-- .../impl/xmlstorage/exist/State.java | 50 ++++++++------ .../xmlstorage/exist/XMLStorageManager.java | 3 + .../testsuite/AFRegistrationSample.xml | 0 .../{ => stubs}/testsuite/BackupTester.java | 6 +- .../stubs/testsuite/RestoreTester.java | 65 ++++++++++++++++++ .../testsuite/ServiceMap_CNRPrivate.xml | 0 .../{ => stubs}/testsuite/ShutdownTester.java | 2 +- .../testsuite/XQueryExecuteTester.java | 2 +- .../{ => stubs}/testsuite/query-example.xq | 0 19 files changed, 288 insertions(+), 98 deletions(-) rename src/org/gcube/informationsystem/collector/{ => stubs}/testsuite/AFRegistrationSample.xml (100%) rename src/org/gcube/informationsystem/collector/{ => stubs}/testsuite/BackupTester.java (90%) create mode 100644 src/org/gcube/informationsystem/collector/stubs/testsuite/RestoreTester.java rename src/org/gcube/informationsystem/collector/{ => stubs}/testsuite/ServiceMap_CNRPrivate.xml (100%) rename src/org/gcube/informationsystem/collector/{ => stubs}/testsuite/ShutdownTester.java (79%) rename src/org/gcube/informationsystem/collector/{ => stubs}/testsuite/XQueryExecuteTester.java (97%) rename src/org/gcube/informationsystem/collector/{ => stubs}/testsuite/query-example.xq (100%) mode change 100644 => 100755 diff --git a/etc/deploy-jndi-config.xml b/etc/deploy-jndi-config.xml index c45dd10..10d0458 100755 --- a/etc/deploy-jndi-config.xml +++ b/etc/deploy-jndi-config.xml @@ -6,6 +6,12 @@ + + + + diff --git a/schema/XMLStorageAccess.wsdl b/schema/XMLStorageAccess.wsdl index 062c1d5..4add0cd 100644 --- a/schema/XMLStorageAccess.wsdl +++ b/schema/XMLStorageAccess.wsdl @@ -20,11 +20,26 @@ - + - + - + + + + + + + + + + + + + + + + @@ -55,21 +70,32 @@ ============================================================--> - + - + - - + + + + + + + + + + + + + diff --git a/src/org/gcube/informationsystem/collector/impl/contexts/ICServiceContext.java b/src/org/gcube/informationsystem/collector/impl/contexts/ICServiceContext.java index 95583a9..e0549d7 100644 --- a/src/org/gcube/informationsystem/collector/impl/contexts/ICServiceContext.java +++ b/src/org/gcube/informationsystem/collector/impl/contexts/ICServiceContext.java @@ -41,7 +41,7 @@ public class ICServiceContext extends GCUBEServiceContext { /** {@inheritDoc} */ @Override protected void onReady() throws Exception { - + State.initialize(); } /** {@inheritDoc} */ diff --git a/src/org/gcube/informationsystem/collector/impl/porttypes/XMLStorageAccess.java b/src/org/gcube/informationsystem/collector/impl/porttypes/XMLStorageAccess.java index 161b65a..7cede70 100644 --- a/src/org/gcube/informationsystem/collector/impl/porttypes/XMLStorageAccess.java +++ b/src/org/gcube/informationsystem/collector/impl/porttypes/XMLStorageAccess.java @@ -1,10 +1,13 @@ 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.BackupFailedFaultType; -import org.gcube.informationsystem.collector.stubs.XMLStorageUnavailableFaultType; +import org.gcube.informationsystem.collector.stubs.BackupNotAvailableFaultType; +import org.gcube.informationsystem.collector.stubs.XMLStorageNotAvailableFaultType; import org.gcube.common.core.contexts.GCUBEServiceContext; import org.gcube.common.core.porttypes.GCUBEPortType; import org.gcube.common.core.types.VOID; @@ -29,15 +32,15 @@ public class XMLStorageAccess extends GCUBEPortType { /** * Backups the current content of the XMLStorage * @throws BackupFailedFaultType if the backup fails - * @throws XMLStorageUnavailableFaultType if the XMLStorage is not available (may be corrupted) + * @throws XMLStorageNotAvailableFaultType if the XMLStorage is not available (may be corrupted) */ - public VOID backup(VOID params) throws BackupFailedFaultType, XMLStorageUnavailableFaultType { + public VOID backup(VOID params) throws BackupFailedFaultType, XMLStorageNotAvailableFaultType { try { State.getDataManager().backup(); } catch (XMLDBException e) { logger.error("Failed to backup", e); - throw new XMLStorageUnavailableFaultType(); + throw new XMLStorageNotAvailableFaultType(); } catch (Exception e) { logger.error("Failed to backup", e); BackupFailedFaultType fault = new BackupFailedFaultType(); @@ -47,6 +50,20 @@ public class XMLStorageAccess extends GCUBEPortType { return new VOID(); } + public VOID restore(VOID params) throws BackupNotAvailableFaultType, XMLStorageNotAvailableFaultType { + + try { + State.getDataManager().restore(); + } catch (IOException e) { + logger.error("Failed to backup", e); + BackupNotAvailableFaultType fault = new BackupNotAvailableFaultType(); + fault.addFaultDetailString("No valid backup has been found"); + throw fault; + } + + return new VOID(); + + } /** * Disposes the XMLStorage @@ -54,6 +71,9 @@ public class XMLStorageAccess extends GCUBEPortType { * @throws BaseFaultType if the shutdown fails */ public void dispose() throws BaseFaultType { + + //request the backup before to shutdown + this.backup(new VOID()); /*try { logger.info("Dispose operation invoked"); logger.info("trying to shutdown the storage instances..."); diff --git a/src/org/gcube/informationsystem/collector/impl/state/AggregatorRegisteredResource.java b/src/org/gcube/informationsystem/collector/impl/state/AggregatorRegisteredResource.java index 598f528..a086816 100755 --- a/src/org/gcube/informationsystem/collector/impl/state/AggregatorRegisteredResource.java +++ b/src/org/gcube/informationsystem/collector/impl/state/AggregatorRegisteredResource.java @@ -252,8 +252,7 @@ public class AggregatorRegisteredResource extends AggregatorServiceGroupResource aentry.dispose(); logger.info("Delivered resource stored with success"); } catch (Exception e) { - logger.error("When managing aggregator content:" + e.getMessage()); - logger.error("returned exception ", e); + logger.error("An error occurred when managing aggregator content, the resource has NOT be stored successfully", e); } } diff --git a/src/org/gcube/informationsystem/collector/impl/xmlstorage/backup/BackupsRootFolder.java b/src/org/gcube/informationsystem/collector/impl/xmlstorage/backup/BackupsRootFolder.java index 7f190e5..943c427 100644 --- a/src/org/gcube/informationsystem/collector/impl/xmlstorage/backup/BackupsRootFolder.java +++ b/src/org/gcube/informationsystem/collector/impl/xmlstorage/backup/BackupsRootFolder.java @@ -1,6 +1,7 @@ package org.gcube.informationsystem.collector.impl.xmlstorage.backup; import java.io.File; +import java.io.FilenameFilter; import java.io.IOException; import java.lang.reflect.Constructor; import java.util.Calendar; @@ -18,10 +19,16 @@ public class BackupsRootFolder { private static final long serialVersionUID = 6054398926161291140L; - private final static String backupsRoot = ICServiceContext.getContext().getPersistenceRoot().getAbsolutePath() + File.separator + "backups" + File.separator; - + private static String backupDir = (String) ICServiceContext.getContext().getProperty("backupDir", true); + private static GCUBELog logger = new GCUBELog(BackupsRootFolder.class); + static { + if (! new File(backupDir).isAbsolute()) //make it absolute + backupDir = ICServiceContext.getContext().getPersistenceRoot().getAbsolutePath() + File.separator + backupDir + File.separator; + + } + /** * Creates a new backup folder * @@ -30,7 +37,7 @@ public class BackupsRootFolder { */ public static BackupFolder createBackupFolder() throws IOException { - final String backupFolder = backupsRoot + File.separator + buildBackupFolderName(); + final String backupFolder = backupDir + File.separator + buildBackupFolderName(); File backup = new File(backupFolder); if (!backup.mkdirs()) throw new IOException("Unable to create the backup folder"); @@ -40,15 +47,16 @@ public class BackupsRootFolder { @SuppressWarnings("unchecked") - public T getLastBackup(Class backupType) throws IOException { + public T getLastBackup(Class backupType, FilenameFilter ... filter) throws IOException { - File rootFolder = new File(backupsRoot); + File rootFolder = new File(backupDir); if (!rootFolder.exists()) throw new IOException("Unable to read the backup folder"); //look for the most recent backup - File[] files = rootFolder.listFiles(); + File[] files = (filter != null && filter[0] != null) ? files = rootFolder.listFiles(filter[0]) : rootFolder.listFiles(); + long lastModified = 0; T lastBackup = null; for (File file : files) { @@ -65,7 +73,7 @@ public class BackupsRootFolder { if (lastBackup == null) throw new IOException("Unable to find a valid backup folder"); - logger.debug("last backup found in " + lastBackup.getAbsolutePath()); + logger.info("last backup found in " + lastBackup.getAbsolutePath()); return lastBackup; } diff --git a/src/org/gcube/informationsystem/collector/impl/xmlstorage/backup/Scheduler.java b/src/org/gcube/informationsystem/collector/impl/xmlstorage/backup/Scheduler.java index 09240e5..f36241b 100644 --- a/src/org/gcube/informationsystem/collector/impl/xmlstorage/backup/Scheduler.java +++ b/src/org/gcube/informationsystem/collector/impl/xmlstorage/backup/Scheduler.java @@ -1,6 +1,7 @@ package org.gcube.informationsystem.collector.impl.xmlstorage.backup; -import org.gcube.common.core.utils.handlers.GCUBEScheduledHandler; +import org.gcube.common.core.utils.logging.GCUBELog; + /** * Scheduler for periodic XMLStorage backups @@ -8,32 +9,45 @@ import org.gcube.common.core.utils.handlers.GCUBEScheduledHandler; * @author Manuele Simi (ISTI-CNR) * */ -public abstract class Scheduler extends GCUBEScheduledHandler { +public abstract class Scheduler implements Runnable { + + /** scheduler logger */ + protected static GCUBELog logger = new GCUBELog(Scheduler.class); + + private int intervalInMS = 24 * 3600 * 1000; //default, 1 day + + /** + * @param intervalInHours the interval expressed in hours between two backups + */ + public Scheduler(int intervalInHours) { + this.intervalInMS = intervalInHours * 3600 * 1000; + } + + public Scheduler() {} + + + public void run() { + + do { + try { + Thread.sleep(this.intervalInMS); + this.doBackup(); + } catch (InterruptedException e) { + logger.error("Unable to sleep (yawn)", e); + } catch (Exception e) { + logger.error("Unable to backup", e); + } + + } while (Thread.interrupted()); + + //logger.info("Backup Scheduler was interrupted"); + } /** - * @param interval - * @param mode - * @param handler + * Performs the backup + * + * @throws Exception if the backup fails */ - public Scheduler(Configuration configuration) { - super(configuration.getInterval(), Mode.EAGER); - } - - public class Configuration { - long interval; - - /** - * @return the interval - */ - public long getInterval() { - return interval; - } - - /** - * @param interval the interval to set - */ - public void setInterval(long interval) { - this.interval = interval; - } - } -} + protected abstract void doBackup() throws Exception; + +} \ No newline at end of file diff --git a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/DataManager.java b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/DataManager.java index 590bcb6..30523ab 100644 --- a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/DataManager.java +++ b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/DataManager.java @@ -10,7 +10,9 @@ import org.xml.sax.SAXException; import org.xmldb.api.base.XMLDBException; import org.gcube.common.core.utils.logging.GCUBELog; +import org.gcube.informationsystem.collector.impl.contexts.ICServiceContext; import org.gcube.informationsystem.collector.impl.xmlstorage.backup.BackupsRootFolder; +import org.gcube.informationsystem.collector.impl.xmlstorage.backup.Scheduler; /** * Data Manager @@ -20,19 +22,21 @@ import org.gcube.informationsystem.collector.impl.xmlstorage.backup.BackupsRootF */ public class DataManager extends XMLStorageManager { - private static GCUBELog logger = new GCUBELog(DataManager.class); + private final static GCUBELog logger = new GCUBELog(DataManager.class); + + private static ExistScheduler scheduler = null; /** * Backups the current content of the XMLStorage * @throws Exception */ - public void backup() throws IOException, Exception { + public synchronized void backup() throws IOException, Exception { //run the eXist's ConsistencyCheckTask //info: http://www.exist-db.org/backup.html //source: http://exist.svn.sourceforge.net/viewvc/exist/branches/eXist-stable-1.2/src/org/exist/backup/ExportMain.java?revision=8695&view=markup - logger.info("backup requested"); + logger.info("Backup requested"); ConsistencyCheckTask check = new ConsistencyCheckTask(); Properties props = new Properties(); props.setProperty("output", BackupsRootFolder.createBackupFolder().getAbsolutePath()); //The directory to which the backup is written @@ -41,6 +45,7 @@ public class DataManager extends XMLStorageManager { check.configure(null, props); //configuration is null, since we pass an absolute path as backup folder check.execute(BrokerPool.getInstance().get(org.exist.security.SecurityManager.SYSTEM_USER)); + logger.info("Backup completed"); //alternative backup way /*Backup backup = new Backup("admin", "admin", BackupsRootFolder.createBackupFolder().getAbsolutePath(), XmldbURI.create(URI + DBBroker.ROOT_COLLECTION)); try { @@ -62,7 +67,9 @@ public class DataManager extends XMLStorageManager { * @throws ParserConfigurationException * @throws Exception */ - public void restore() throws IOException { + public synchronized void restore() throws IOException { + + logger.info("Restore requested"); ExistBackupFolder lastBackup = this.getLastBackup(); Restore restore = null; @@ -80,6 +87,7 @@ public class DataManager extends XMLStorageManager { try { restore.restore(false, null); + logger.info("Restore completed"); } catch (XMLDBException e) { logger.error(e); } catch (SAXException e) { @@ -88,10 +96,32 @@ public class DataManager extends XMLStorageManager { } - + /** + * Retrieves the last backup + * @return the last backup file or folder + * @throws IOException if the backup cannot be found + */ private ExistBackupFolder getLastBackup() throws IOException { - return new BackupsRootFolder().getLastBackup(ExistBackupFolder.class); + return new BackupsRootFolder().getLastBackup(ExistBackupFolder.class, ExistBackupFolder.getFilter()); + } + + /** + * Gets the scheduler for automatic and periodic backups of the XMLStorage.
+ * Automatic backups are scheduled via the scheduledBackupInHours variable in the service's JNDI. + * If this variable is missing the automatic backups are not performed. + * @return the scheduler or null if no automatic backup was configured + */ + public static Scheduler getScheduler() { + if (scheduler != null) + return scheduler; + String interval = (String) ICServiceContext.getContext().getProperty("scheduledBackupInHours", false); + if (interval == null) + return null; // scheduled backups are not requested + + //create a new scheduler if requested + scheduler = new ExistScheduler(Integer.valueOf(interval)); + return scheduler; } } diff --git a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/ExistBackupFolder.java b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/ExistBackupFolder.java index 44c768a..e328764 100644 --- a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/ExistBackupFolder.java +++ b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/ExistBackupFolder.java @@ -1,5 +1,7 @@ package org.gcube.informationsystem.collector.impl.xmlstorage.exist; +import java.io.File; +import java.io.FilenameFilter; import java.io.IOException; import org.gcube.informationsystem.collector.impl.xmlstorage.backup.BackupFolder; @@ -21,11 +23,13 @@ public class ExistBackupFolder extends BackupFolder { super(pathname); } - /** {@inheritDoc} */ - @Override - protected boolean isValid() { - //TODO: should check the existence of "db/__contents__.xml" - return true; + protected static FilenameFilter getFilter() { + return new FilenameFilter() { + public boolean accept(File dir, String name) { + if ((name.endsWith(".zip") || name.endsWith(".ZIP"))) + return true; + //TODO: should check the existence of "db/__contents__.xml" ?? + return false; + }}; } - } diff --git a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/ExistScheduler.java b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/ExistScheduler.java index a99c1ab..2f05a36 100644 --- a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/ExistScheduler.java +++ b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/ExistScheduler.java @@ -2,6 +2,7 @@ package org.gcube.informationsystem.collector.impl.xmlstorage.exist; import org.gcube.informationsystem.collector.impl.xmlstorage.backup.Scheduler; + /** * Exist Scheduler for periodic backups * @@ -10,12 +11,16 @@ import org.gcube.informationsystem.collector.impl.xmlstorage.backup.Scheduler; */ public class ExistScheduler extends Scheduler { - /** - * @param configuration - */ - public ExistScheduler(Configuration configuration) { - super(configuration); + /**{@inheritDoc} */ + public ExistScheduler(int intervalInHours) { + super(intervalInHours); + } + + + /**{@inheritDoc} */ + @Override + protected void doBackup() throws Exception { + org.gcube.informationsystem.collector.impl.xmlstorage.exist.State.getDataManager().backup(); } - } diff --git a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/State.java b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/State.java index fce5f8d..7469e5e 100755 --- a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/State.java +++ b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/State.java @@ -1,11 +1,9 @@ package org.gcube.informationsystem.collector.impl.xmlstorage.exist; +import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.informationsystem.collector.impl.contexts.ICServiceContext; import org.gcube.informationsystem.collector.impl.persistence.AggregatorPersistentResource; -import org.globus.wsrf.config.ContainerConfig; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; @@ -20,19 +18,20 @@ import java.util.Collections; public class State { /** - * Connection to eXist used to store data + * Connection to XMLStorage for data management */ - private static DataManager storageManager; + private static DataManager dataManager; /** - * Connection to eXist used to query the database + * Connection to XMLStorage for querying the data */ private static QueryManager queryManager; - /** - * Thread that periodically sweeps the database from expired resources - */ + /** Thread that periodically sweeps the XMLStorage from expired resources */ public static Thread sweeperT; + + /** Thread that periodically backups the XMLStorage */ + public static Thread schedulerT; /** * List of recently deleted resources. It is used to avoid the storage of RPs of a deleted @@ -40,7 +39,7 @@ public class State { */ public static List deletedResources = Collections.synchronizedList(new ArrayList()); - private static Log logger = LogFactory.getLog(State.class.getName()); + private static GCUBELog logger = new GCUBELog(State.class); /** * Initializes the eXist DB connections using during the service life @@ -57,7 +56,7 @@ public class State { if (Boolean.valueOf((String) ICServiceContext.getContext().getProperty("deleteRPsOnStartup", true))) { // cleanup the RPs collection logger.info("deleting all RPs..."); - State.storageManager.deleteAllProperties(); + State.dataManager.deleteAllProperties(); } else { logger.info("all RPs previously stored are keept in the storage"); } @@ -67,14 +66,21 @@ public class State { .getProperty("resourceExpirationTimeInMillis", true))); State.sweeperT = new Thread(sweeper); State.sweeperT.start(); - + + //start the scheduler for automatic backups (if any) + org.gcube.informationsystem.collector.impl.xmlstorage.backup.Scheduler scheduler = DataManager.getScheduler(); + if (scheduler != null) { + schedulerT = new Thread(scheduler); + schedulerT.start(); + } + logger.info("IC service initialization completed"); } private static void initializeDataManager() throws Exception { // open the connection used to store resources - State.storageManager = new DataManager(); - storageManager.initialize(); + State.dataManager = new DataManager(); + dataManager.initialize(); } private static void initializeQueryManager() throws Exception { @@ -87,9 +93,9 @@ public class State { * * @return the container base dir */ - public static String getBaseDirectory() { - return ContainerConfig.getBaseDirectory(); - } +// public static String getBaseDirectory() { +// return ContainerConfig.getBaseDirectory(); +// } /** * Releases all the State resources @@ -98,15 +104,18 @@ public class State { */ public static void dispose() throws Exception { logger.info("Disposing IC service's resources..."); - State.storageManager.shutdown(); + State.sweeperT.interrupt(); + State.schedulerT.interrupt(); + State.dataManager.shutdown(); State.queryManager.shutdown(); + } /** - * @return the storageManager + * @return the dataManager */ public static DataManager getDataManager() { - return storageManager; + return dataManager; } /** @@ -127,6 +136,5 @@ public class State { logger.debug(keys.nextElement()); } logger.debug("Exist home: " + System.getProperty("exist.home")); - logger.debug("Class path: " + System.getProperty("java.class.path")); } } diff --git a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/XMLStorageManager.java b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/XMLStorageManager.java index 031f944..11a7225 100755 --- a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/XMLStorageManager.java +++ b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/XMLStorageManager.java @@ -171,6 +171,9 @@ public class XMLStorageManager { logger.error("failed to create collection " + collectionName + "!"); logger.error("" + edb.getCause()); + } catch (java.lang.NullPointerException e) { + logger.fatal("the XMLStorage is GONE!! a Restore is needed"); + } return currentCollection; } diff --git a/src/org/gcube/informationsystem/collector/testsuite/AFRegistrationSample.xml b/src/org/gcube/informationsystem/collector/stubs/testsuite/AFRegistrationSample.xml similarity index 100% rename from src/org/gcube/informationsystem/collector/testsuite/AFRegistrationSample.xml rename to src/org/gcube/informationsystem/collector/stubs/testsuite/AFRegistrationSample.xml diff --git a/src/org/gcube/informationsystem/collector/testsuite/BackupTester.java b/src/org/gcube/informationsystem/collector/stubs/testsuite/BackupTester.java similarity index 90% rename from src/org/gcube/informationsystem/collector/testsuite/BackupTester.java rename to src/org/gcube/informationsystem/collector/stubs/testsuite/BackupTester.java index d962f12..1596187 100644 --- a/src/org/gcube/informationsystem/collector/testsuite/BackupTester.java +++ b/src/org/gcube/informationsystem/collector/stubs/testsuite/BackupTester.java @@ -1,4 +1,4 @@ -package org.gcube.informationsystem.collector.testsuite; +package org.gcube.informationsystem.collector.stubs.testsuite; import java.net.URL; import java.rmi.RemoteException; @@ -9,7 +9,7 @@ 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.XMLStorageAccessPortType; -import org.gcube.informationsystem.collector.stubs.XMLStorageUnavailableFaultType; +import org.gcube.informationsystem.collector.stubs.XMLStorageNotAvailableFaultType; import org.gcube.informationsystem.collector.stubs.service.XMLStorageAccessServiceLocator; @@ -53,7 +53,7 @@ public class BackupTester { logger.info("Submitting backup request..."); try { port.backup(new VOID()); - } catch (XMLStorageUnavailableFaultType e) { + } catch (XMLStorageNotAvailableFaultType e) { logger.error("",e); } catch (BackupFailedFaultType e) { logger.error("",e); diff --git a/src/org/gcube/informationsystem/collector/stubs/testsuite/RestoreTester.java b/src/org/gcube/informationsystem/collector/stubs/testsuite/RestoreTester.java new file mode 100644 index 0000000..b23c3a4 --- /dev/null +++ b/src/org/gcube/informationsystem/collector/stubs/testsuite/RestoreTester.java @@ -0,0 +1,65 @@ +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.BackupNotAvailableFaultType; +import org.gcube.informationsystem.collector.stubs.XMLStorageAccessPortType; +import org.gcube.informationsystem.collector.stubs.XMLStorageNotAvailableFaultType; +import org.gcube.informationsystem.collector.stubs.service.XMLStorageAccessServiceLocator; + +/** + * Tester for Restore operation of the + * gcube/informationsystem/collector/XMLStorageAccess portType + * + * @author Manuele Simi (ISTI-CNR) + * + */ +public class RestoreTester { + + private static GCUBEClientLog logger = new GCUBEClientLog(RestoreTester.class); + + /** + * @param args + *
    + *
  1. IC host + *
  2. IC port + *
  3. Caller Scope + *
+ */ + public static void main(String[] args) { + + /*if (args.length != 3) { + logger.fatal("Usage: RestoreTester "); + 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) { + e.printStackTrace(); + } + + logger.info("Submitting restore request..."); + try { + port.restore(new VOID()); + } catch (XMLStorageNotAvailableFaultType e) { + logger.error("",e); + } catch (BackupNotAvailableFaultType e) { + logger.error("",e); + } catch (RemoteException e) { + logger.error("",e); + } + + } + +} diff --git a/src/org/gcube/informationsystem/collector/testsuite/ServiceMap_CNRPrivate.xml b/src/org/gcube/informationsystem/collector/stubs/testsuite/ServiceMap_CNRPrivate.xml similarity index 100% rename from src/org/gcube/informationsystem/collector/testsuite/ServiceMap_CNRPrivate.xml rename to src/org/gcube/informationsystem/collector/stubs/testsuite/ServiceMap_CNRPrivate.xml diff --git a/src/org/gcube/informationsystem/collector/testsuite/ShutdownTester.java b/src/org/gcube/informationsystem/collector/stubs/testsuite/ShutdownTester.java similarity index 79% rename from src/org/gcube/informationsystem/collector/testsuite/ShutdownTester.java rename to src/org/gcube/informationsystem/collector/stubs/testsuite/ShutdownTester.java index 2426a4b..baef53d 100644 --- a/src/org/gcube/informationsystem/collector/testsuite/ShutdownTester.java +++ b/src/org/gcube/informationsystem/collector/stubs/testsuite/ShutdownTester.java @@ -1,4 +1,4 @@ -package org.gcube.informationsystem.collector.testsuite; +package org.gcube.informationsystem.collector.stubs.testsuite; /** * TODO: Manuele, don't forget to add a comment for this new type!! diff --git a/src/org/gcube/informationsystem/collector/testsuite/XQueryExecuteTester.java b/src/org/gcube/informationsystem/collector/stubs/testsuite/XQueryExecuteTester.java similarity index 97% rename from src/org/gcube/informationsystem/collector/testsuite/XQueryExecuteTester.java rename to src/org/gcube/informationsystem/collector/stubs/testsuite/XQueryExecuteTester.java index b0166ca..18cc4bd 100644 --- a/src/org/gcube/informationsystem/collector/testsuite/XQueryExecuteTester.java +++ b/src/org/gcube/informationsystem/collector/stubs/testsuite/XQueryExecuteTester.java @@ -1,4 +1,4 @@ -package org.gcube.informationsystem.collector.testsuite; +package org.gcube.informationsystem.collector.stubs.testsuite; import java.io.BufferedReader; diff --git a/src/org/gcube/informationsystem/collector/testsuite/query-example.xq b/src/org/gcube/informationsystem/collector/stubs/testsuite/query-example.xq old mode 100644 new mode 100755 similarity index 100% rename from src/org/gcube/informationsystem/collector/testsuite/query-example.xq rename to src/org/gcube/informationsystem/collector/stubs/testsuite/query-example.xq