Commit 0896e36b authored by shake's avatar shake
Browse files

Basic handling for file registered state

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@147 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent 9f2b15f0
...@@ -562,8 +562,7 @@ public final class AuditThread extends Thread implements CancelCallback { ...@@ -562,8 +562,7 @@ public final class AuditThread extends Thread implements CancelCallback {
if (validator != null) { if (validator != null) {
itemMap.put(token, item); itemMap.put(token, item);
try { try {
validator.add( validator.add(item.getFileDigest(), token);
item.getFileDigest(), token);
} catch (InterruptedException e) { } catch (InterruptedException e) {
abortException = e; abortException = e;
} }
......
...@@ -60,7 +60,7 @@ import javax.persistence.TemporalType; ...@@ -60,7 +60,7 @@ import javax.persistence.TemporalType;
* P - partner does not have this file * P - partner does not have this file
* D - partner file has different digest * D - partner file has different digest
* @author toaster * @author toaster
* 1.6+ * 1.6b+
* R - file registered but not ready for auditing * R - file registered but not ready for auditing
*/ */
@Entity @Entity
......
...@@ -45,6 +45,7 @@ import javax.persistence.NoResultException; ...@@ -45,6 +45,7 @@ import javax.persistence.NoResultException;
import javax.persistence.Query; import javax.persistence.Query;
/** /**
* Class to register directories from a token store
* *
* @author shake * @author shake
*/ */
......
...@@ -76,7 +76,8 @@ public class IngestStore extends EntityManagerServlet { ...@@ -76,7 +76,8 @@ public class IngestStore extends EntityManagerServlet {
Map<String, Token> batchTokens = new HashMap<String, Token>(); Map<String, Token> batchTokens = new HashMap<String, Token>();
if (item != null && !item.isDirectory()) if (item != null && !item.isDirectory())
throw new ServletException("Selected item is not a directory " + item.getPath()); throw new ServletException( "Selected item is not a directory "
+ item.getPath() );
if (!ServletFileUpload.isMultipartContent(request)) { if (!ServletFileUpload.isMultipartContent(request)) {
throw new ServletException("No file attached"); throw new ServletException("No file attached");
......
...@@ -170,7 +170,7 @@ public class IngestThread extends Thread { ...@@ -170,7 +170,7 @@ public class IngestThread extends Thread {
updateToken(em, token, item, coll, identifier); updateToken(em, token, item, coll, identifier);
} }
// With large Token Stores, we can get a large number of transactions // With large Token Stores, we get a large number of transactions
// Flusing and Clearing the EM helps to clear some memory // Flusing and Clearing the EM helps to clear some memory
if ( numTransactions > 7000 ) { if ( numTransactions > 7000 ) {
em.flush(); em.flush();
...@@ -184,7 +184,6 @@ public class IngestThread extends Thread { ...@@ -184,7 +184,6 @@ public class IngestThread extends Thread {
trans = null; trans = null;
em = null; em = null;
finished(); finished();
// System.out.println("Thread finished: " + numTransactions);
} }
} }
......
...@@ -32,6 +32,7 @@ package edu.umiacs.ace.monitor.register; ...@@ -32,6 +32,7 @@ package edu.umiacs.ace.monitor.register;
import edu.umiacs.ace.monitor.core.Collection; import edu.umiacs.ace.monitor.core.Collection;
import edu.umiacs.ace.monitor.core.Token; import edu.umiacs.ace.monitor.core.Token;
import edu.umiacs.ace.util.PersistUtil;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
...@@ -40,6 +41,8 @@ import java.util.Map; ...@@ -40,6 +41,8 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
/** /**
* *
...@@ -49,12 +52,14 @@ public class IngestThreadFactory extends Thread{ ...@@ -49,12 +52,14 @@ public class IngestThreadFactory extends Thread{
private Map<String, Token> tokens; private Map<String, Token> tokens;
private List<IngestThread> threads; private List<IngestThread> threads;
private IngestDirectory idThread; private IngestDirectory idThread;
private Collection coll;
// private EntityTransaction trans; // private EntityTransaction trans;
// private EntityManager em = PersistUtil.getEntityManager(); // private EntityManager em = PersistUtil.getEntityManager();
public IngestThreadFactory(Map<String, Token> tokens, Collection coll){ public IngestThreadFactory(Map<String, Token> tokens, Collection coll){
this.tokens = tokens; this.tokens = tokens;
this.coll = coll;
//this.trans = em.getTransaction(); //this.trans = em.getTransaction();
threads = new ArrayList<IngestThread>(); threads = new ArrayList<IngestThread>();
...@@ -95,7 +100,16 @@ public class IngestThreadFactory extends Thread{ ...@@ -95,7 +100,16 @@ public class IngestThreadFactory extends Thread{
Logger.getLogger( Logger.getLogger(
IngestThreadFactory.class.getName()).log(Level.SEVERE, null, ex); IngestThreadFactory.class.getName()).log(Level.SEVERE, null, ex);
}finally{ }finally{
// System.out.println("All threads finished"); if ( !getNewTokens().isEmpty() ) {
System.out.println("Setting collection to errrrr");
coll.setState('E');
EntityManager em = PersistUtil.getEntityManager();
EntityTransaction trans = em.getTransaction();
trans.begin();
em.merge(coll);
trans.commit();
trans = null;
}
} }
} }
...@@ -118,13 +132,6 @@ public class IngestThreadFactory extends Thread{ ...@@ -118,13 +132,6 @@ public class IngestThreadFactory extends Thread{
joinThreads(); joinThreads();
} }
private void removeThreads() {
for ( IngestThread it: threads ) {
threads.remove(it);
it = null;
}
}
public Set<String> getUpdatedTokens() { public Set<String> getUpdatedTokens() {
Set<String> updated = new HashSet<String>(); Set<String> updated = new HashSet<String>();
for (IngestThread it: threads) { for (IngestThread it: threads) {
......
...@@ -135,6 +135,9 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library. ...@@ -135,6 +135,9 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
<c:when test="${selectedFile.root.state eq 'M'}"> <c:when test="${selectedFile.root.state eq 'M'}">
File Missing File Missing
</c:when> </c:when>
<c:when test="${selectedFile.root.state eq 'R'}">
File Registered
</c:when>
<c:when test="${selectedFile.root.state eq 'P'}"> <c:when test="${selectedFile.root.state eq 'P'}">
Remote File Missing Remote File Missing
</c:when> </c:when>
......
...@@ -130,6 +130,9 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library. ...@@ -130,6 +130,9 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
<c:when test="${item.state eq 'D'}"> <c:when test="${item.state eq 'D'}">
Remote Corrupt Remote Corrupt
</c:when> </c:when>
<c:when test="${item.state eq 'R'}">
File Registered
</c:when>
<c:otherwise> <c:otherwise>
${item.state} ${item.state}
</c:otherwise> </c:otherwise>
......
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