Commit 157126ac authored by toaster's avatar toaster
Browse files

1.5 checkin

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@11 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent cb8baa92
/*
/*
* Copyright (c) 2007-@year@, University of Maryland
* All rights reserved.
*
......@@ -31,8 +31,12 @@ package edu.umiacs.ace.monitor.core;
import edu.umiacs.ace.driver.StorageDriver;
import edu.umiacs.ace.driver.StorageDriverFactory;
import edu.umiacs.ace.monitor.log.LogEnum;
import edu.umiacs.ace.monitor.log.LogEvent;
import edu.umiacs.ace.monitor.log.LogEventManager;
import edu.umiacs.ace.util.EntityManagerServlet;
import java.io.IOException;
import java.util.Date;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.servlet.RequestDispatcher;
......@@ -55,12 +59,14 @@ public class ClearResourceServlet extends EntityManagerServlet {
if ( c != null ) {
if (c.getStorage() != null)
{
LogEventManager lem = new LogEventManager(new Date().getTime(), c);
EntityTransaction t = em.getTransaction();
t.begin();
StorageDriver sd = StorageDriverFactory.createStorageAccess(c, em);
LogEvent event = lem.createCollectionEvent(LogEnum.REMOVE_STORAGE_DRIVER, "Remove configuration for " + c.getStorage());
sd.remove(em);
c.setStorage(null);
em.persist(event);
em.merge(c);
t.commit();
}
......
......@@ -77,7 +77,7 @@ public enum LogEnum {
REMOTE_FILE_MISSING(15, "Remote File Missing", "not corresponding file on remote site"),
REMOTE_FILE_ONLINE(16, "Remote File Online", "Remote file marked as active"),
REMOVE_STORAGE_DRIVER(17, "Remove Storage Driver", "Configured storage driver was removed"),
STORAGE_DRIVER_ADDED(18, "Add Storage Driver", "New Storage Driver configured"),
//STORAGE_DRIVER_ADDED(18, "Add Storage Driver", "New Storage Driver configured"),
COLLECTION_REGISTERED(19,"Collection Registered", "Collection registered for monitoring"),
/////////// audit start/stops
/**
......@@ -157,8 +157,8 @@ public enum LogEnum {
return REMOTE_FILE_ONLINE;
case 17:
return REMOVE_STORAGE_DRIVER;
case 18:
return STORAGE_DRIVER_ADDED;
// case 18:
// return STORAGE_DRIVER_ADDED;
case 20:
return FILE_AUDIT_START;
case 21:
......
......@@ -31,7 +31,6 @@
package edu.umiacs.ace.monitor.log;
import edu.umiacs.ace.monitor.core.Collection;
import edu.umiacs.ace.monitor.peers.PeerCollection;
import edu.umiacs.util.Strings;
import java.util.Date;
import javax.persistence.EntityManager;
......@@ -43,247 +42,16 @@ import javax.persistence.EntityTransaction;
*/
public class LogEventManager {
// private EntityManager em;
private long session;
private Collection collection;
// public LogEventManager( EntityManager em, long session ) {
// this.em = em;
// this.session = session;
// }
public LogEventManager( long session, Collection collection ) {
// this.em = em;
this.session = session;
this.collection = collection;
}
/**
* Start auding of a collection
* @param c
*/
// public void fileAuditStart( Collection c, String message ) {
// LogEvent event =
// getBaseEvent(c.getDirectory(), c);
// event.setLogType(LogEnum.FILE_AUDIT_START.getType());
// event.setDescription(message);
// persist(event);
// }
// public void tokenAuditStart( Collection c ) {
// LogEvent event =
// getBaseEvent(c.getDirectory(), c);
// event.setLogType(LogEnum.TOKEN_AUDIT_START.getType());
// persist(event);
// }
/**
* Log finish colleciton audit
*
* @param c collection that finished
* @param message descriptive message, optional
*/
// public void finishFileAudit( Collection c, String message ) {
// LogEvent event =
// getBaseEvent(c.getDirectory(), c);
// event.setDescription(message);
// event.setLogType(LogEnum.FILE_AUDIT_FINISH.getType());
// persist(event);
// }
/**
* Log finish colleciton token audit
*
* @param c collection that finished
* @param message descriptive message, optional
*/
// public void finishTokenAudit( Collection c, String message ) {
// LogEvent event =
// getBaseEvent(c.getDirectory(), c);
// event.setDescription(message);
// event.setLogType(LogEnum.TOKEN_AUDIT_FINISH.getType());
// persist(event);
// }
//public voi
/**
* Register a new file found
*
* @param path
* @param c
*/
// public void foundNewFile( String path, Collection c ) {
// LogEvent event = getBaseEvent(path, c);
//// event.setDescription(c.getDirectory() + path);
//
// event.setLogType(LogEnum.FILE_NEW.getType());
//
// persist(event);
//
// }
// public void removeFile( String path, Collection c ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.REMOVE_ITEM.getType());
// persist(event);
// }
/**
* Mark a file as transitioning to online.
*
* @param path
* @param c
*/
// public void fileOnline( String path, Collection c ) {
// LogEvent event = getBaseEvent(path, c);
//// event.setDescription(c.getDirectory() + path);
//
// event.setLogType(LogEnum.FILE_ONLINE.getType());
//
// persist(event);
//
// }
/**
* Create communication error event. Returns the event rather than persisting
* for use in a larger transaction.
*
* @param path
* @param c
* @param reason
* @return
*/
// public LogEvent imsCommError( String path, Collection c, Throwable reason ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.UNKNOWN_IMS_COMMUNICATION_ERROR.getType());
// event.setDescription(Strings.exceptionAsString(reason));
// return event;
//// persist(event);
//
// }
// public LogEvent missingRemoteFile( String path, Collection c, PeerCollection pc ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.REMOTE_FILE_MISSING.getType());
// event.setDescription(pc.getSite().getRemoteURL());
// return event;
//// persist(event);
//
// }
// public LogEvent onlineRemoteFile( String path, Collection c ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.REMOTE_FILE_ONLINE.getType());
// return event;
//// persist(event);
//
// }
// public LogEvent missingFile( String path, Collection c ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.FILE_MISSING.getType());
// return event;
//// persist(event);
//
// }
// public void corruptFile( String path, Collection c, String expected,
// String seenHash ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.FILE_CORRUPT.getType());
// event.setDescription(
// "Expected digest: " + expected + " Saw: " + seenHash);
//
// persist(event);
//
// }
// public LogEvent corruptRemoteFile( String path, Collection c, String expected,
// String seenHash, PeerCollection pc ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.REMOTE_FILE_CORRUPT.getType());
// event.setDescription(
// "Expected digest: " + expected + " Saw: " + seenHash + " site: "
// + pc.getSite().getRemoteURL());
// return event;
//// persist(event);
//
// }
// public LogEvent validToken( String path, Collection c ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.TOKEN_VALID.getType());
// return event;
// }
// public LogEvent invalidToken( String path, Collection c, String message ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.TOKEN_INVALID.getType());
// event.setDescription(message);
// return event;
// }
/**
* persists
*
* @param path
* @param c
*/
// public void missingToken( String path, Collection c ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.MISSING_TOKEN.getType());
// }
/**
* presists
*
* @param path
* @param c
* @param message
*/
// public void errorReading( String path, Collection c, String message ) {
// LogEvent event = getBaseEvent(path, c);
// event.setLogType(LogEnum.ERROR_READING.getType());
// event.setDescription(message);
//
// persist(event);
// }
// public void systemError( Collection coll, Throwable reason ) {
// systemError(coll, Strings.exceptionAsString(reason));
//// LogEvent event = getBaseEvent(null, coll);
//// event.setLogType(LogEnum.SYSTEM_ERROR.getType());
//// event.setDescription(Strings.exceptionAsString(reason));
////
//// persist(event);
// }
// public void systemError( Collection coll, String reason ) {
// LogEvent event = getBaseEvent(null, coll);
// event.setLogType(LogEnum.SYSTEM_ERROR.getType());
// event.setDescription(reason);
//
// persist(event);
// }
/**
* Log abort replication. Results in both a system error and a finish log event
*
* @param coll
* @param message
* @param reason
*/
// public void abortSite( Collection coll, String message,
// Throwable reason ) {
// LogEvent event = getBaseEvent(null, coll);
// event.setLogType(LogEnum.SYSTEM_ERROR.getType());
// event.setDescription(message + Strings.exceptionAsString(reason));
//
// persist(event);
//// finishFileAudit(coll, "Audit aborted: " + message);
// }
public void persistItemEvent( LogEnum logType, String path,
String msg, EntityManager em )
{
......@@ -329,21 +97,4 @@ public class LogEventManager {
return createItemEvent(logType, null, message);
}
// private void persist( LogEvent event ) {
//// EntityTransaction trans = em.getTransaction();
//// trans.begin();
//// em.persist(event);
//// trans.commit();
// }
// private LogEvent getBaseEvent( String path, Collection c ) {
// LogEvent event = new LogEvent();
//
// event.setDate(new Date());
// event.setSession(session);
// event.setCollection(c);
// event.setPath(path);
//
// return event;
// }
}
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