Commit 136f2b99 authored by toaster's avatar toaster
Browse files

irods threaded driver

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@114 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent 6f6b0764
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
* Maryland Institute for Advanced Computer Study. * Maryland Institute for Advanced Computer Study.
*/ */
// $Id$ // $Id$
package edu.umiacs.ace.driver.irods; package edu.umiacs.ace.driver.irods;
import edu.umiacs.ace.driver.DriverStateBean; import edu.umiacs.ace.driver.DriverStateBean;
...@@ -71,7 +70,7 @@ public class IrodsAccess extends StorageDriver { ...@@ -71,7 +70,7 @@ public class IrodsAccess extends StorageDriver {
private IrodsSetting ic; private IrodsSetting ic;
private EntityManager em; private EntityManager em;
public IrodsAccess( Collection c, EntityManager em ) { public IrodsAccess(Collection c, EntityManager em) {
super(c); super(c);
try { try {
this.em = em; this.em = em;
...@@ -81,7 +80,7 @@ public class IrodsAccess extends StorageDriver { ...@@ -81,7 +80,7 @@ public class IrodsAccess extends StorageDriver {
try { try {
ic = (IrodsSetting) q.getSingleResult(); ic = (IrodsSetting) q.getSingleResult();
LOG.trace("Loaded existing irodsSetting"); LOG.trace("Loaded existing irodsSetting");
} catch ( NoResultException e ) { } catch (NoResultException e) {
ic = new IrodsSetting(); ic = new IrodsSetting();
ic.setZone("tempZone"); ic.setZone("tempZone");
ic.setPassword("rods"); ic.setPassword("rods");
...@@ -95,7 +94,7 @@ public class IrodsAccess extends StorageDriver { ...@@ -95,7 +94,7 @@ public class IrodsAccess extends StorageDriver {
et.commit(); et.commit();
LOG.trace("Persisted new irodsSetting"); LOG.trace("Persisted new irodsSetting");
} }
} catch ( Exception e ) { } catch (Exception e) {
LOG.error("Error loading settings: " + e); LOG.error("Error loading settings: " + e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -103,16 +102,19 @@ public class IrodsAccess extends StorageDriver { ...@@ -103,16 +102,19 @@ public class IrodsAccess extends StorageDriver {
} }
@Override @Override
public AuditIterable<FileBean> getWorkList( final String digestAlgorithm, public AuditIterable<FileBean> getWorkList(final String digestAlgorithm,
final PathFilter filter, final MonitoredItem[] startPathList ) { final PathFilter filter, final MonitoredItem[] startPathList) {
final DriverStateBean statlist = new DriverStateBean(); // final DriverStateBean statlist = new DriverStateBean();
final ConnectOperation co = new ConnectOperation(ic.getServer(), ic.getPort(), final ConnectOperation co = new ConnectOperation(ic.getServer(), ic.getPort(),
ic.getUsername(), ic.getPassword(), ic.getZone()); ic.getUsername(), ic.getPassword(), ic.getZone());
final IrodsIterator2 it = new IrodsIterator2(startPathList, filter, // final IrodsIterator2 it = new IrodsIterator2(startPathList, filter,
digestAlgorithm, statlist, ic.getCollection().getDirectory(), co); // digestAlgorithm, statlist, ic.getCollection().getDirectory(), co);
final IrodsThreadedDirectoryIterator it = new IrodsThreadedDirectoryIterator(getCollection(), startPathList, filter, co);
//Collection c,
//MonitoredItem[] basePath, PathFilter filter, String digestAlgorithm,
//ConnectOperation co
return new AuditIterable<FileBean>() { return new AuditIterable<FileBean>() {
@Override @Override
...@@ -127,9 +129,9 @@ public class IrodsAccess extends StorageDriver { ...@@ -127,9 +129,9 @@ public class IrodsAccess extends StorageDriver {
@Override @Override
public DriverStateBean[] getState() { public DriverStateBean[] getState() {
return new DriverStateBean[] {statlist}; // return new DriverStateBean[] {statlist};
return it.getStatebeans();
} }
}; };
} }
...@@ -139,7 +141,7 @@ public class IrodsAccess extends StorageDriver { ...@@ -139,7 +141,7 @@ public class IrodsAccess extends StorageDriver {
} }
@Override @Override
public void setParameters( Map m ) { public void setParameters(Map m) {
boolean newTx; boolean newTx;
LOG.trace("Setting irods parameters"); LOG.trace("Setting irods parameters");
...@@ -150,17 +152,17 @@ public class IrodsAccess extends StorageDriver { ...@@ -150,17 +152,17 @@ public class IrodsAccess extends StorageDriver {
ic.setZone(getSingleParam(m, PARAM_ZONE)); ic.setZone(getSingleParam(m, PARAM_ZONE));
EntityTransaction et = em.getTransaction(); EntityTransaction et = em.getTransaction();
newTx = et.isActive(); newTx = et.isActive();
if ( !newTx ) { if (!newTx) {
et.begin(); et.begin();
} }
PersistUtil.getEntityManager().merge(ic); PersistUtil.getEntityManager().merge(ic);
if ( !newTx ) { if (!newTx) {
et.commit(); et.commit();
} }
} }
@Override @Override
public String checkParameters( Map m, String path ) { public String checkParameters(Map m, String path) {
boolean good = false; boolean good = false;
String server, username, password, zone; String server, username, password, zone;
int port; int port;
...@@ -173,7 +175,7 @@ public class IrodsAccess extends StorageDriver { ...@@ -173,7 +175,7 @@ public class IrodsAccess extends StorageDriver {
LOG.trace("IRODS checkParameters"); LOG.trace("IRODS checkParameters");
good = (!Strings.isEmpty(server) && !Strings.isEmpty(zone) && Strings.isValidInt(getSingleParam(m, good = (!Strings.isEmpty(server) && !Strings.isEmpty(zone) && Strings.isValidInt(getSingleParam(m,
PARAM_PORT)) && !Strings.isEmpty(username) && !Strings.isEmpty(password)); PARAM_PORT)) && !Strings.isEmpty(username) && !Strings.isEmpty(password));
if ( !good ) { if (!good) {
return "Settings empty, check settings"; return "Settings empty, check settings";
} }
port = Integer.parseInt(getSingleParam(m, PARAM_PORT)); port = Integer.parseInt(getSingleParam(m, PARAM_PORT));
...@@ -190,14 +192,14 @@ public class IrodsAccess extends StorageDriver { ...@@ -190,14 +192,14 @@ public class IrodsAccess extends StorageDriver {
IrodsOperations ops = new IrodsOperations(co); IrodsOperations ops = new IrodsOperations(co);
RodsObjStat_PI stat = ops.stat(path); RodsObjStat_PI stat = ops.stat(path);
if ( stat == null || stat.getObjType() != ObjTypeEnum.COLL_OBJ_T ) { if (stat == null || stat.getObjType() != ObjTypeEnum.COLL_OBJ_T) {
return "Directory listed does not exist in IRODS"; return "Directory listed does not exist in IRODS";
} }
connect.closeConnection(); connect.closeConnection();
return null; return null;
} catch ( IOException ioe ) { } catch (IOException ioe) {
LOG.info("Exception thrown attempting to validate settings", ioe); LOG.info("Exception thrown attempting to validate settings", ioe);
return "Error connecting to irods: " + ioe.getMessage(); return "Error connecting to irods: " + ioe.getMessage();
...@@ -207,10 +209,10 @@ public class IrodsAccess extends StorageDriver { ...@@ -207,10 +209,10 @@ public class IrodsAccess extends StorageDriver {
} }
private String getSingleParam( Map m, String paramName ) { private String getSingleParam(Map m, String paramName) {
Object o = m.get(paramName); Object o = m.get(paramName);
if ( o == null ) { if (o == null) {
return null; return null;
} }
...@@ -219,7 +221,7 @@ public class IrodsAccess extends StorageDriver { ...@@ -219,7 +221,7 @@ public class IrodsAccess extends StorageDriver {
} }
@Override @Override
public void remove( EntityManager em ) { public void remove(EntityManager em) {
LOG.trace("Removing irods parameters"); LOG.trace("Removing irods parameters");
em.remove(ic); em.remove(ic);
} }
...@@ -230,7 +232,7 @@ public class IrodsAccess extends StorageDriver { ...@@ -230,7 +232,7 @@ public class IrodsAccess extends StorageDriver {
} }
@Override @Override
public InputStream getItemInputStream( String itemPath ) throws IOException { public InputStream getItemInputStream(String itemPath) throws IOException {
//TODO: iRODS getItemInputStream //TODO: iRODS getItemInputStream
// throw new UnsupportedOperationException("Not supported yet."); // throw new UnsupportedOperationException("Not supported yet.");
ConnectOperation co = new ConnectOperation(ic.getServer(), ic.getPort(), ConnectOperation co = new ConnectOperation(ic.getServer(), ic.getPort(),
......
...@@ -9,13 +9,17 @@ ...@@ -9,13 +9,17 @@
or the username. or the username.
url - machine name and database name url - machine name and database name
- in the form jdbc:mysql://<YOUR_DB_SERVER>/<ACE_DB>
username - username used to connect to database username - username used to connect to database
password - password used for database password - password used for database
'name' is the resource name used by the web app to refer to this 'name' is the resource name used by the web app to refer to this
database and NOT the database name, do not change unless you want bad database and NOT the database name, do not change unless you want bad
things to happen.--> things to happen.-->
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/aceamdb" password="password" testOnBorrow="true" type="javax.sql.DataSource" url="jdbc:mysql://naraapp12/aceam2" username="aceam" validationQuery="SELECT 1"/> <Resource auth="Container" testOnBorrow="true" type="javax.sql.DataSource"
validationQuery="SELECT 1" driverClassName="com.mysql.jdbc.Driver" maxActive="20"
maxIdle="10" maxWait="-1" name="jdbc/aceamdb"
password="password" url="jdbc:mysql://naraapp12/aceam2" username="aceam" />
<!--Mail server to use when mailing reports. You will need to set this if <!--Mail server to use when mailing reports. You will need to set this if
you want reports to be mailed properly.--> you want reports to be mailed properly.-->
<Parameter name="mail.server" value="localhost.localdomain"/> <Parameter name="mail.server" value="localhost.localdomain"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment