Commit defcb68d authored by toaster's avatar toaster
Browse files

version 1.6beta checkin

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@33 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent 2bb95a3e
......@@ -30,6 +30,8 @@
// $Id$
package edu.umiacs.ace.driver;
import java.util.Arrays;
/**
*
* @author toaster
......@@ -84,7 +86,11 @@ public class FileBean {
* @param parentPathList
*/
public void setPathList( String[] pathList ) {
this.pathList = pathList;
if ( pathList != null ) {
this.pathList = Arrays.copyOf(pathList, pathList.length);
} else {
this.pathList = null;
}
}
public String[] getPathList() {
......
......@@ -51,6 +51,18 @@ public class QueryThrottle implements ServletContextListener {
private static final String PARAM_BPS = "throttle.bps";
private static final Logger LOG = Logger.getLogger(QueryThrottle.class);
private static void setMinWait( long minWait ) {
QueryThrottle.minWait = minWait;
}
private static void setMaxBps( long maxBps ) {
QueryThrottle.maxBps = maxBps;
}
public static long getMaxBps() {
return maxBps;
}
public static void waitToRun() throws InterruptedException {
if ( minWait <= 0 ) {
return;
......@@ -68,9 +80,6 @@ public class QueryThrottle implements ServletContextListener {
}
public static long getMaxBps() {
return maxBps;
}
private static synchronized void workCheck() {
synchronized ( PARAM_TIME ) {
......@@ -84,13 +93,13 @@ public class QueryThrottle implements ServletContextListener {
if ( Strings.isValidInt(time) ) {
minWait = Integer.parseInt(time);
setMinWait(Integer.parseInt(time));
LOG.info("Setting query throttle minwait to " + minWait);
}
String maxBpsString = sce.getServletContext().getInitParameter(PARAM_BPS);
if ( Strings.isValidLong(maxBpsString) ) {
maxBps = Long.parseLong(maxBpsString);
setMaxBps(Long.parseLong(maxBpsString));
}
......
......@@ -112,7 +112,7 @@ public final class RetrieveItemServlet extends EntityManagerServlet {
writeItemToResponse(response, collectionPath, coll, em);
}
LOG.debug("Collection: " + collection + " item: " + (item != null ? item.getPath() : ""));
LOG.debug("Retrieved item, Collection: " + collection + " item: " + item.getPath());
}
......
......@@ -240,10 +240,11 @@ public class BenchmarkAccess extends StorageDriver {
private String[] createPathList() {
String[] retString = new String[arrayCounter.length + 1];
String path = "";
StringBuilder path = new StringBuilder();
for ( int idx = 0; idx < arrayCounter.length; idx++ ) {
path = path + "/dir-" + arrayCounter[idx];
retString[arrayCounter.length - idx] = path;
path.append("/dir-");
path.append(arrayCounter[idx]);
retString[arrayCounter.length - idx] = path.toString();
}
retString[0] = path + "/file-" + currFile;
......
......@@ -137,11 +137,11 @@ public class FilterServlet extends EntityManagerServlet {
Map paramMap = request.getParameterMap();
if ( !Strings.isEmpty(paramMap.get(PARAM_MODIFY)) ) {
for ( Object param : paramMap.keySet() ) {
String name = (String) param;
if ( name.startsWith(PARAM_REGEX_PREFIX) && !Strings.isEmpty(paramMap.get(
param)) ) {
String[] regex = (String[]) paramMap.get(param);
for ( Object o : paramMap.entrySet() ) {
Map.Entry entry = (Map.Entry) o;
String name = (String) entry.getKey();
if ( name.startsWith(PARAM_REGEX_PREFIX) && !Strings.isEmpty(entry.getValue()) ) {
String[] regex = (String[]) entry.getValue();
String count = name.substring(PARAM_REGEX_PREFIX.length());
int type = Integer.parseInt(((String[]) paramMap.get(
PARAM_TYPE_PREFIX + count))[0]);
......@@ -179,11 +179,11 @@ public class FilterServlet extends EntityManagerServlet {
}
}
public class ErrorList<T> extends ArrayList<T> {
public static class ErrorList<T> extends ArrayList<T> {
private boolean error = false;
public ErrorList() {
private ErrorList() {
}
public ErrorList( List l ) {
......@@ -195,12 +195,12 @@ public class FilterServlet extends EntityManagerServlet {
}
}
public class MyFilterEntry extends FilterEntry {
public static class MyFilterEntry extends FilterEntry {
private String error = null;
private boolean matchesTest = false;
public MyFilterEntry() {
private MyFilterEntry() {
}
public MyFilterEntry( FilterEntry fe ) {
......
......@@ -60,7 +60,7 @@ import org.apache.log4j.Logger;
*
* @author toaster
*/
public class SrbAccess extends StorageDriver {
public final class SrbAccess extends StorageDriver {
private static final Logger LOG = Logger.getLogger(SrbAccess.class);
private static final String PARAM_SERVER = "server";
......@@ -254,7 +254,7 @@ public class SrbAccess extends StorageDriver {
return new WrappedInputStream(sfis, sfs, cp);
}
class WrappedInputStream extends FilterInputStream {
static class WrappedInputStream extends FilterInputStream {
private ConnectionPool cp;
private SRBFileSystem sfs;
......
......@@ -64,14 +64,14 @@ import org.apache.log4j.NDC;
*
* @author toaster
*/
public class SrbDirectoryIterator implements Iterator<FileBean> {
public final class SrbDirectoryIterator implements Iterator<FileBean> {
private DriverStateBean[] statebeans;
private static final int MAX_THREADS = 5;
private static final int RETRY = 5;
private static final Logger LOG = Logger.getLogger(
SrbDirectoryIterator.class);
private Collection collection;
// private Collection collection;
private ConnectionPool pool;
private boolean finished = false;
private LinkedBlockingQueue<FileBean> readyList = new LinkedBlockingQueue<FileBean>();
......@@ -86,7 +86,7 @@ public class SrbDirectoryIterator implements Iterator<FileBean> {
public SrbDirectoryIterator( Collection c, SrbSettings settings,
MonitoredItem[] basePath, PathFilter filter, String digestAlgorithm ) {
this.collection = c;
// this.collection = c;
this.pool = settings.createPool();
this.root = c.getDirectory();
this.filter = filter;
......
......@@ -192,28 +192,6 @@ public class SwapFileAccess extends StorageDriver {
return null;
}
private class MyConnectListener implements ConnectionListener {
Operation result = null;
@Override
public synchronized void connectionEvent( InetSocketAddress isa, Operation oprtn ) {
if ( result == null && oprtn != Operation.DISCONNECT ) {
result = oprtn;
notifyAll();
}
}
// block till result
public synchronized Operation getResult() throws InterruptedException {
while ( result == null ) {
wait();
}
return result;
}
}
private String getSingleParam( Map m, String paramName ) {
Object o = m.get(paramName);
......@@ -356,4 +334,28 @@ public class SwapFileAccess extends StorageDriver {
return connection.getInputStream();
}
private static class MyConnectListener implements ConnectionListener {
Operation result = null;
@Override
public synchronized void connectionEvent( InetSocketAddress isa, Operation oprtn ) {
if ( result == null && oprtn != Operation.DISCONNECT ) {
result = oprtn;
notifyAll();
}
}
// block till result
public synchronized Operation getResult() throws InterruptedException {
while ( result == null ) {
wait();
}
return result;
}
}
}
......@@ -64,7 +64,7 @@ import org.swap.client.SwapFile;
*
* @author toaster
*/
public class SwapIterator implements Iterator<FileBean> {
public final class SwapIterator implements Iterator<FileBean> {
private Queue<SwapFile> dirsToProcess = new LinkedList<SwapFile>();
private LinkedBlockingQueue<SwapFile> filesToProcess = new LinkedBlockingQueue<SwapFile>();
......
......@@ -82,7 +82,6 @@ public class CollectionCountContext implements ServletContextListener {
Thread.currentThread().setName("Startup Count Thread");
NDC.push("[Count]");
lock.lock();
// {
LOG.debug("Starting count for all collections");
try {
EntityManager em = PersistUtil.getEntityManager();
......@@ -91,6 +90,7 @@ public class CollectionCountContext implements ServletContextListener {
for ( Object o : collQuery.getResultList() ) {
if ( abort ) {
LOG.info("Collection count aborting, tomcat probably shutting down");
return;
}
queryCollection((Collection) o);
......@@ -211,6 +211,8 @@ public class CollectionCountContext implements ServletContextListener {
long totalErrors = 0;
while ( rs.next() ) {
if (abort)
return;
char state = rs.getString(1).charAt(0);
long count = rs.getLong(2);
......@@ -271,7 +273,7 @@ public class CollectionCountContext implements ServletContextListener {
SQL.release(rs);
SQL.release(ps);
SQL.release(connection);
LOG.debug("Finished count on " + c.getName());
LOG.trace("Finished count on " + c.getName());
}
}
......
......@@ -101,7 +101,7 @@ public class StatusServlet extends EntityManagerServlet {
request.getSession().setAttribute(SESSION_WORKINGCOLLECTION, csb);
} else if ( request.getSession().getAttribute(
SESSION_WORKINGCOLLECTION) != null && ((CollectionSummaryBean) request.getSession().getAttribute(
SESSION_WORKINGCOLLECTION)).getCollection().getId() == col.getId() ) {
SESSION_WORKINGCOLLECTION)).getCollection().getId().equals(col.getId()) ) {
request.getSession().setAttribute(SESSION_WORKINGCOLLECTION, csb);
}
......
......@@ -160,12 +160,15 @@ public class BrowseServlet extends EntityManagerServlet {
}
public class FileBean {
public static class FileBean {
MonitoredItem root;
String name;
String itemProof;
private FileBean() {
}
public String getItemProof() {
return itemProof;
}
......
......@@ -150,7 +150,7 @@ public class DirectoryTree {
}
public class DirectoryNode implements Comparable {
public static class DirectoryNode implements Comparable {
private boolean expanded = false;
private boolean directory = false;
......@@ -159,6 +159,9 @@ public class DirectoryTree {
List<DirectoryNode> children = new ArrayList<DirectoryNode>();
private char status;
private DirectoryNode() {
}
public boolean isExpanded() {
return expanded;
}
......@@ -187,6 +190,52 @@ public class DirectoryTree {
return String.valueOf(status);
}
@Override
public int hashCode() {
int hash = 5;
hash = 11 * hash + (this.expanded ? 1 : 0);
hash = 11 * hash + (this.directory ? 1 : 0);
hash = 11 * hash + (this.path != null ? this.path.hashCode() : 0);
hash = 11 * hash + (int) (this.id ^ (this.id >>> 32));
hash = 11 * hash + (this.children != null ? this.children.hashCode() : 0);
hash = 11 * hash + this.status;
return hash;
}
@Override
public boolean equals( Object obj ) {
if ( obj == null ) {
return false;
}
if ( getClass() != obj.getClass() ) {
return false;
}
final DirectoryNode other = (DirectoryNode) obj;
if ( this.expanded != other.expanded ) {
return false;
}
if ( this.directory != other.directory ) {
return false;
}
if ( (this.path == null) ? (other.path != null) : !this.path.equals(other.path) ) {
return false;
}
if ( this.id != other.id ) {
return false;
}
if ( this.children != other.children &&
(this.children == null || !this.children.equals(other.children)) ) {
return false;
}
if ( this.status != other.status ) {
return false;
}
return true;
}
@Override
public int compareTo( Object o ) {
if ( o instanceof DirectoryNode ) {
DirectoryNode n = (DirectoryNode) o;
......
......@@ -34,6 +34,7 @@ import edu.umiacs.ace.driver.StorageDriver;
import edu.umiacs.ace.driver.StorageDriverFactory;
import edu.umiacs.ace.util.PersistUtil;
import edu.umiacs.ace.monitor.core.Collection;
import edu.umiacs.ace.monitor.core.MonitoredItem;
import edu.umiacs.util.Strings;
import java.util.List;
import java.util.Timer;
......@@ -119,10 +120,13 @@ public final class AuditConfigurationContext implements ServletContextListener {
AuditTokens.cancellAll();
}
public class PauseBean {
public static class PauseBean {
private boolean paused = false;
private PauseBean() {
}
public void setPaused( boolean paused ) {
this.paused = paused;
}
......@@ -137,11 +141,11 @@ public final class AuditConfigurationContext implements ServletContextListener {
}
}
class MyTimerTask extends TimerTask {
static class MyTimerTask extends TimerTask {
private PauseBean pb;
public MyTimerTask( PauseBean pb ) {
private MyTimerTask( PauseBean pb ) {
this.pb = pb;
}
......@@ -174,7 +178,7 @@ public final class AuditConfigurationContext implements ServletContextListener {
LOG.debug("No last sync for " + c.getName() + " running");
sa = StorageDriverFactory.createStorageAccess(c,
em);
AuditThreadFactory.createThread(c, sa, null);
AuditThreadFactory.createThread(c, sa, (MonitoredItem[])null);
} else {
long syncTime = c.getLastSync().getTime();
long currTime = System.currentTimeMillis();
......@@ -184,7 +188,7 @@ public final class AuditConfigurationContext implements ServletContextListener {
+ " greater than " + (c.getCheckPeriod() * HOUR * 24));
sa = StorageDriverFactory.createStorageAccess(c,
em);
AuditThreadFactory.createThread(c, sa, null);
AuditThreadFactory.createThread(c, sa, (MonitoredItem[]) null);
} else {
LOG.trace("No Sync on " + c.getName());
}
......
......@@ -32,7 +32,6 @@ package edu.umiacs.ace.monitor.audit;
import edu.umiacs.ace.ims.api.IMSService;
import edu.umiacs.ace.ims.api.TokenValidator;
import edu.umiacs.ace.ims.ws.TokenResponse;
import edu.umiacs.ace.util.PersistUtil;
import edu.umiacs.ace.monitor.core.MonitoredItem;
import edu.umiacs.ace.monitor.core.MonitoredItemManager;
......@@ -43,7 +42,6 @@ import edu.umiacs.ace.token.AceToken;
import edu.umiacs.ace.util.TokenUtil;
import edu.umiacs.util.Strings;
import java.security.MessageDigest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
......@@ -56,7 +54,7 @@ import org.apache.log4j.Logger;
*
* @author toaster
*/
public class AuditTokens extends Thread implements CancelCallback {
public final class AuditTokens extends Thread implements CancelCallback {
private static final Map<Collection, AuditTokens> runningThreads =
new HashMap<Collection, AuditTokens>();
......@@ -78,7 +76,7 @@ public class AuditTokens extends Thread implements CancelCallback {
private AuditTokens( Collection collection ) {
this.collection = collection;
session = new Date().getTime();
session = System.currentTimeMillis();
logManager = new LogEventManager(session, collection);
this.start();
}
......
......@@ -42,10 +42,7 @@ import edu.umiacs.ace.ims.ws.TokenRequest;
import edu.umiacs.ace.ims.ws.TokenResponse;
import edu.umiacs.ace.monitor.core.Collection;
import edu.umiacs.ace.monitor.log.LogEnum;
import edu.umiacs.ace.token.AceToken;
import edu.umiacs.util.Strings;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......
......@@ -533,13 +533,13 @@ public class CollectionCompare {
};
}
class ReadIterator implements Iterator<SourceFile> {
static class ReadIterator implements Iterator<SourceFile> {
private BufferedReader input;
private SourceFile next = null;
private String prefix = null;
public ReadIterator( InputStream input, String prefix ) {
private ReadIterator( InputStream input, String prefix ) {
this.prefix = prefix;
this.input = new BufferedReader(new InputStreamReader(input));
next = readNext();
......@@ -595,12 +595,12 @@ public class CollectionCompare {
}
}
class SourceFile {
static class SourceFile {
private String name;
private String digest;
public SourceFile( String name, String digest ) {
private SourceFile( String name, String digest ) {
this.name = name;
this.digest = digest;
}
......@@ -622,14 +622,14 @@ public class CollectionCompare {
}
}
public class DifferingName implements Comparable<DifferingName> {
public static class DifferingName implements Comparable<DifferingName> {
private String compString;
private String sourceName;
private String destinationName;
private String digest;
public DifferingName( String sourceName, String destinationName,
private DifferingName( String sourceName, String destinationName,
String digest ) {
this.sourceName = sourceName;
this.destinationName = destinationName;
......@@ -681,14 +681,14 @@ public class CollectionCompare {
}
}
public class DifferingDigest implements Comparable<DifferingDigest> {
public static class DifferingDigest implements Comparable<DifferingDigest> {
private String name;
private String sourceDigest;
private String targetDigest;
private String compString;
public DifferingDigest( String name, String sourceDigest,
private DifferingDigest( String name, String sourceDigest,
String targetDigest ) {
this.name = name;
this.sourceDigest = sourceDigest;
......@@ -720,6 +720,7 @@ public class CollectionCompare {
this.sourceDigest = sourceDigest;
}
@Override
public int compareTo( DifferingDigest o ) {
return compString.compareTo(o.compString);
}
......
......@@ -186,13 +186,13 @@ public class CompareServlet extends EntityManagerServlet {
}
class TableCompareRunnable implements Runnable {
static class TableCompareRunnable implements Runnable {
private CollectionCompare cc;
private Collection c;
private MonitoredItem baseItem;
public TableCompareRunnable( CollectionCompare cc, Collection c,
private TableCompareRunnable( CollectionCompare cc, Collection c,
MonitoredItem baseItem ) {
this.cc = cc;
this.c = c;
......
......@@ -109,6 +109,8 @@ public class DuplicateReportServlet extends EntityManagerServlet {
rs.close();
pst.close();
LOG.info("Duplicate report on " + collection.getName() + " time "
+ (System.currentTimeMillis() - startTime) + " total dups " + totalDups);
} catch ( SQLException e ) {
throw new ServletException(e);
......@@ -125,8 +127,7 @@ public class DuplicateReportServlet extends EntityManagerServlet {
request.setAttribute(PAGE_LIST, duplicateCount);