Commit c94b3630 authored by Michael Ritter's avatar Michael Ritter
Browse files

Remove a collection from active maps and trigger a group summary update

parent 688ec119
...@@ -44,9 +44,9 @@ import javax.sql.DataSource; ...@@ -44,9 +44,9 @@ import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
...@@ -63,16 +63,16 @@ public class CollectionCountContext implements ServletContextListener { ...@@ -63,16 +63,16 @@ public class CollectionCountContext implements ServletContextListener {
public static final String CTX_STARTUP = "startup_complete"; public static final String CTX_STARTUP = "startup_complete";
private static final Logger LOG = Logger.getLogger( private static final Logger LOG = Logger.getLogger(
CollectionCountContext.class); CollectionCountContext.class);
private static Map<Collection, Long> fileCountMap = new HashMap<>(); private static Map<Collection, Long> fileCountMap = new ConcurrentHashMap<>();
private static Map<Collection, Long> fileActiveMap = new HashMap<>(); private static Map<Collection, Long> fileActiveMap = new ConcurrentHashMap<>();
private static Map<Collection, Long> fileCorruptMap = new HashMap<>(); private static Map<Collection, Long> fileCorruptMap = new ConcurrentHashMap<>();
private static Map<Collection, Long> fileMissingMap = new HashMap<>(); private static Map<Collection, Long> fileMissingMap = new ConcurrentHashMap<>();
private static Map<Collection, Long> fileMissingTokenMap = new HashMap<>(); private static Map<Collection, Long> fileMissingTokenMap = new ConcurrentHashMap<>();
private static Map<Collection, Long> fileTokenMismatchMap = new HashMap<>(); private static Map<Collection, Long> fileTokenMismatchMap = new ConcurrentHashMap<>();
private static Map<Collection, Long> totalErrorMap = new HashMap<>(); private static Map<Collection, Long> totalErrorMap = new ConcurrentHashMap<>();
private static Map<Collection, Long> totalSizeMap = new HashMap<>(); private static Map<Collection, Long> totalSizeMap = new ConcurrentHashMap<>();
private static Map<Collection, Long> fileRemoteMissing = new HashMap<>(); private static Map<Collection, Long> fileRemoteMissing = new ConcurrentHashMap<>();
private static Map<Collection, Long> fileRemoteCorrupt = new HashMap<>(); private static Map<Collection, Long> fileRemoteCorrupt = new ConcurrentHashMap<>();
private static AtomicInteger totalCollections = new AtomicInteger(0); private static AtomicInteger totalCollections = new AtomicInteger(0);
private static Lock lock = new ReentrantLock(); private static Lock lock = new ReentrantLock();
private static boolean abort = false; private static boolean abort = false;
...@@ -217,8 +217,20 @@ public class CollectionCountContext implements ServletContextListener { ...@@ -217,8 +217,20 @@ public class CollectionCountContext implements ServletContextListener {
totalCollections.incrementAndGet(); totalCollections.incrementAndGet();
} }
public static void decrementTotalCollections() { public static void decrementTotalCollections(Collection collection) {
totalCollections.decrementAndGet(); totalCollections.decrementAndGet();
fileCountMap.remove(collection);
fileActiveMap.remove(collection);
fileCorruptMap.remove(collection);
fileMissingMap.remove(collection);
fileMissingTokenMap.remove(collection);
fileTokenMismatchMap.remove(collection);
totalErrorMap.remove(collection);
totalSizeMap.remove(collection);
fileRemoteMissing.remove(collection);
fileRemoteCorrupt.remove(collection);
GroupSummaryContext.updateGroup(collection.getGroup());
} }
public static int getTotalCollections() { public static int getTotalCollections() {
......
...@@ -96,7 +96,7 @@ public class ManageCollectionServlet extends EntityManagerServlet { ...@@ -96,7 +96,7 @@ public class ManageCollectionServlet extends EntityManagerServlet {
String paramCheckResponse = null; String paramCheckResponse = null;
/** /*
* Modification, view, or removal of an existing collection * Modification, view, or removal of an existing collection
* if we have an int, and its > 0, and it is the key for a resource * if we have an int, and its > 0, and it is the key for a resource
*/ */
...@@ -109,16 +109,16 @@ public class ManageCollectionServlet extends EntityManagerServlet { ...@@ -109,16 +109,16 @@ public class ManageCollectionServlet extends EntityManagerServlet {
} }
/** /*
* Tst to see if we're removing a collection * Tst to see if we're removing a collection
*/ */
if (!Strings.isEmpty(request.getParameter(PARAM_REMOVE)) if (!Strings.isEmpty(request.getParameter(PARAM_REMOVE))
&& request.getParameter(PARAM_REMOVE).toLowerCase().equals("yes")) { && request.getParameter(PARAM_REMOVE).toLowerCase().equals("yes")) {
LOG.debug("removing collection" + collection.getName()); LOG.debug("removing collection " + collection.getName());
removeCollection(em, collection, storage); removeCollection(em, collection, storage);
response.sendRedirect("Status?collectionid=-1"); response.sendRedirect("Status?collectionid=-1");
return; return;
} /** } /*
* otherwise, are we updating? * otherwise, are we updating?
*/ */
else if (checkParameters(request) else if (checkParameters(request)
...@@ -132,7 +132,7 @@ public class ManageCollectionServlet extends EntityManagerServlet { ...@@ -132,7 +132,7 @@ public class ManageCollectionServlet extends EntityManagerServlet {
} }
trans.commit(); trans.commit();
dispatcher = request.getRequestDispatcher("collectionfinish.jsp"); dispatcher = request.getRequestDispatcher("collectionfinish.jsp");
} /** } /*
* ok, we're just opening an existing collection for modification * ok, we're just opening an existing collection for modification
* - this should display the storage page since storage will be set * - this should display the storage page since storage will be set
*/ */
...@@ -140,7 +140,7 @@ public class ManageCollectionServlet extends EntityManagerServlet { ...@@ -140,7 +140,7 @@ public class ManageCollectionServlet extends EntityManagerServlet {
LOG.debug("loading existing collection: " + collection.getName()); LOG.debug("loading existing collection: " + collection.getName());
dispatcher = request.getRequestDispatcher("collectionmodify.jsp"); dispatcher = request.getRequestDispatcher("collectionmodify.jsp");
} }
} /** } /*
* its either a new submission, or requesting a blank page. * its either a new submission, or requesting a blank page.
* We shouldn't set storage information here yet, just create the * We shouldn't set storage information here yet, just create the
* new collection and create a blank storage * new collection and create a blank storage
...@@ -209,7 +209,7 @@ public class ManageCollectionServlet extends EntityManagerServlet { ...@@ -209,7 +209,7 @@ public class ManageCollectionServlet extends EntityManagerServlet {
storage.remove(em); storage.remove(em);
} }
em.remove(collection); em.remove(collection);
CollectionCountContext.decrementTotalCollections(); CollectionCountContext.decrementTotalCollections(collection);
trans.commit(); trans.commit();
} }
......
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