ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1301607 - in /ace/trunk: ace-log-servlet/src/main/java/org/apache/ace/server/log/servlet/ ace-log-servlet/src/test/java/org/apache/ace/server/log/servlet/ ace-log/src/test/java/org/apache/ace/log/ ace-managementagent/src/main/java/org/apac...
Date Fri, 16 Mar 2012 16:03:13 GMT
Author: marrs
Date: Fri Mar 16 16:03:13 2012
New Revision: 1301607

URL: http://svn.apache.org/viewvc?rev=1301607&view=rev
Log:
ACE-63 here we go again

Modified:
    ace/trunk/ace-log-servlet/src/main/java/org/apache/ace/server/log/servlet/LogServlet.java
    ace/trunk/ace-log-servlet/src/test/java/org/apache/ace/server/log/servlet/LogServletTest.java
    ace/trunk/ace-log/src/test/java/org/apache/ace/log/LogEventTest.java
    ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java
    ace/trunk/ace-server-log-store/src/main/java/org/apache/ace/server/log/store/impl/LogStoreImpl.java

Modified: ace/trunk/ace-log-servlet/src/main/java/org/apache/ace/server/log/servlet/LogServlet.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-log-servlet/src/main/java/org/apache/ace/server/log/servlet/LogServlet.java?rev=1301607&r1=1301606&r2=1301607&view=diff
==============================================================================
--- ace/trunk/ace-log-servlet/src/main/java/org/apache/ace/server/log/servlet/LogServlet.java
(original)
+++ ace/trunk/ace-log-servlet/src/main/java/org/apache/ace/server/log/servlet/LogServlet.java
Fri Mar 16 16:03:13 2012
@@ -43,15 +43,15 @@ import org.osgi.service.log.LogService;
  *
  * Querying existing audit log event id's:
  * http://host:port/auditlog/query - Return all known event ranges
- * http://host:port/auditlog/query?gwid=myid&logid=123712636323 - Return the event range
belonging to the specified gateway and log id
+ * http://host:port/auditlog/query?tid=myid&logid=123712636323 - Return the event range
belonging to the specified target and log id
  *
  * Accepting new audit log events:
  * http://host:port/auditlog/send - Gets a new log event and puts it in the store, the event
is inside the request and should be a formatted as done in <code>LogEvent.toRepresentation()</code>.
  *
  * Querying existing audit log events:
  * http://host:port/auditlog/receive - Return all known events
- * http://host:port/auditlog/receive?gwid=myid - Return all known events belonging to the
specified gateway ID
- * http://host:port/auditlog/receive?gwid=myid&logid=2374623874 - Return all known events
belonging to the specified gateway ID
+ * http://host:port/auditlog/receive?tid=myid - Return all known events belonging to the
specified target ID
+ * http://host:port/auditlog/receive?tid=myid&logid=2374623874 - Return all known events
belonging to the specified target ID
  *
  * If the request is not correctly formatted or other problems arise error code <code>HttpServletResponse.SC_NOT_FOUND</code>
will be sent in the response.
  */
@@ -68,7 +68,7 @@ public class LogServlet extends HttpServ
     private static final String RECEIVE = "/receive";
 
     // url parameter keys
-    private static final String GWID_KEY = "gwid";
+    private static final String TARGETID_KEY = "tid";
     private static final String FILTER_KEY = "filter";
     private static final String LOGID_KEY = "logid";
     private static final String RANGE_KEY = "range";
@@ -102,21 +102,21 @@ public class LogServlet extends HttpServ
         // 'query' and 'receive' calls are GET calls
 
         String path = request.getPathInfo();
-        String gatewayID = request.getParameter(GWID_KEY);
+        String targetID = request.getParameter(TARGETID_KEY);
         String logID = request.getParameter(LOGID_KEY);
         String filter = request.getParameter(FILTER_KEY);
         String range = request.getParameter(RANGE_KEY);
 
-        m_log.log(LogService.LOG_DEBUG, "Log servlet called: path(" + path + ") gatewayID("
+ gatewayID + ") logID(" + logID + ") range( " + range + ") filter(" + filter +")");
+        m_log.log(LogService.LOG_DEBUG, "Log servlet called: path(" + path + ") targetID("
+ targetID + ") logID(" + logID + ") range( " + range + ") filter(" + filter +")");
         response.setContentType(TEXT_MIMETYPE);
 
         ServletOutputStream output = null;
         try {
             output = response.getOutputStream();
-            if (QUERY.equals(path) && !handleQuery(gatewayID, logID, filter, output))
{
+            if (QUERY.equals(path) && !handleQuery(targetID, logID, filter, output))
{
                 sendError(response, HttpServletResponse.SC_BAD_REQUEST, "Unable to interpret
query");
             }
-            else if (RECEIVE.equals(path) && !handleReceive(gatewayID, logID, range,
filter, output)) {
+            else if (RECEIVE.equals(path) && !handleReceive(targetID, logID, range,
filter, output)) {
                 sendError(response, HttpServletResponse.SC_BAD_REQUEST, "Unable to interpret
receive query");
             }
         }
@@ -136,15 +136,15 @@ public class LogServlet extends HttpServ
     }
 
     // Handle a call to the query 'command'
-    protected boolean handleQuery(String gatewayID, String logID, String filter, ServletOutputStream
output) throws IOException {
-        if ((gatewayID != null) && (logID != null)) {
-            // gateway and log id are specified, return only the range that matches these
id's
-            LogDescriptor range = m_store.getDescriptor(gatewayID, Long.parseLong(logID));
+    protected boolean handleQuery(String targetID, String logID, String filter, ServletOutputStream
output) throws IOException {
+        if ((targetID != null) && (logID != null)) {
+            // target and log id are specified, return only the range that matches these
id's
+            LogDescriptor range = m_store.getDescriptor(targetID, Long.parseLong(logID));
             output.print(range.toRepresentation());
             return true;
         }
-        else if ((gatewayID == null) && (logID == null)) {
-            // no gateway or log id has been specified, return all ranges
+        else if ((targetID == null) && (logID == null)) {
+            // no target or log id has been specified, return all ranges
             List<LogDescriptor> ranges = m_store.getDescriptors();
             for (LogDescriptor range : ranges) {
                 output.print(range.toRepresentation() + "\n");
@@ -155,28 +155,28 @@ public class LogServlet extends HttpServ
     }
 
     // Handle a call to the receive 'command'
-    protected boolean handleReceive(String gatewayID, String logID, String range, String
filter, ServletOutputStream output) throws IOException {
-        if ((gatewayID != null) && (logID != null)) {
-            // gateway and log id are specified, return only the events that are in the range
that matches these id's
+    protected boolean handleReceive(String targetID, String logID, String range, String filter,
ServletOutputStream output) throws IOException {
+        if ((targetID != null) && (logID != null)) {
+            // target and log id are specified, return only the events that are in the range
that matches these id's
             if (range != null) {
-                LogDescriptor storeDescriptor = m_store.getDescriptor(gatewayID, Long.parseLong(logID));
+                LogDescriptor storeDescriptor = m_store.getDescriptor(targetID, Long.parseLong(logID));
                 outputRange(output, new LogDescriptor(storeDescriptor.getTargetID(), storeDescriptor.getLogID(),
new SortedRangeSet(range)));
             }
             else {
-                outputRange(output, m_store.getDescriptor(gatewayID, Long.parseLong(logID)));
+                outputRange(output, m_store.getDescriptor(targetID, Long.parseLong(logID)));
             }
             return true;
         }
-        else if ((gatewayID != null) && (logID == null)) {
-            // gateway id is specified, log id is not, return all events that belong to the
specified gateway id
-            List<LogDescriptor> descriptors = m_store.getDescriptors(gatewayID);
+        else if ((targetID != null) && (logID == null)) {
+            // target id is specified, log id is not, return all events that belong to the
specified target id
+            List<LogDescriptor> descriptors = m_store.getDescriptors(targetID);
             for (LogDescriptor descriptor : descriptors) {
                 outputRange(output, descriptor);
             }
             return true;
         }
-        else if ((gatewayID == null) && (logID == null)) {
-            // no gateway or log id has been specified, return all events
+        else if ((targetID == null) && (logID == null)) {
+            // no target or log id has been specified, return all events
             List<LogDescriptor> descriptors = m_store.getDescriptors();
             for (LogDescriptor descriptor : descriptors) {
                 outputRange(output, descriptor);

Modified: ace/trunk/ace-log-servlet/src/test/java/org/apache/ace/server/log/servlet/LogServletTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-log-servlet/src/test/java/org/apache/ace/server/log/servlet/LogServletTest.java?rev=1301607&r1=1301606&r2=1301607&view=diff
==============================================================================
--- ace/trunk/ace-log-servlet/src/test/java/org/apache/ace/server/log/servlet/LogServletTest.java
(original)
+++ ace/trunk/ace-log-servlet/src/test/java/org/apache/ace/server/log/servlet/LogServletTest.java
Fri Mar 16 16:03:13 2012
@@ -42,9 +42,9 @@ import org.testng.annotations.Test;
 public class LogServletTest {
 
     private LogServlet m_logServlet;
-    private LogDescriptor m_range = new LogDescriptor("gwID", 123, new SortedRangeSet("1-3"));
-    private LogEvent m_event1 = new LogEvent("gwID", 123, 1, 888888, 1, new Properties());
-    private LogEvent m_event2 = new LogEvent("gwID", 123, 2, 888888, 2, new Properties());
+    private LogDescriptor m_range = new LogDescriptor("tID", 123, new SortedRangeSet("1-3"));
+    private LogEvent m_event1 = new LogEvent("tID", 123, 1, 888888, 1, new Properties());
+    private LogEvent m_event2 = new LogEvent("tID", 123, 2, 888888, 2, new Properties());
     private MockLogStore m_mockStore;
 
     @BeforeMethod(alwaysRun = true)
@@ -116,7 +116,7 @@ public class LogServletTest {
             }
             return events;
         }
-        public List<LogDescriptor> getDescriptors(String gatewayID) {
+        public List<LogDescriptor> getDescriptors(String targetID) {
             return null;
         }
         public List<LogDescriptor> getDescriptors() {
@@ -124,7 +124,7 @@ public class LogServletTest {
             ranges.add(m_range);
             return ranges;
         }
-        public LogDescriptor getDescriptor(String gatewayID, long logID) throws IOException
{
+        public LogDescriptor getDescriptor(String targetID, long logID) throws IOException
{
             return m_range;
         }
         public void put(List<LogEvent> events) throws IOException {

Modified: ace/trunk/ace-log/src/test/java/org/apache/ace/log/LogEventTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-log/src/test/java/org/apache/ace/log/LogEventTest.java?rev=1301607&r1=1301606&r2=1301607&view=diff
==============================================================================
--- ace/trunk/ace-log/src/test/java/org/apache/ace/log/LogEventTest.java (original)
+++ ace/trunk/ace-log/src/test/java/org/apache/ace/log/LogEventTest.java Fri Mar 16 16:03:13
2012
@@ -42,7 +42,7 @@ public class LogEventTest {
     @Test(groups = { UNIT })
     public void deserializeLogEvent() {
         LogEvent e = new LogEvent("gwid$kgwid$n$r$$,1,2,3," + AuditEvent.FRAMEWORK_STARTED
+ ",a,1,b,2,c,3");
-        assert e.getTargetID().equals("gwid,gwid\n\r$") : "Gateway ID is not correctly parsed";
+        assert e.getTargetID().equals("gwid,gwid\n\r$") : "Target ID is not correctly parsed";
         assert e.getLogID() == 1 : "Log ID is not correctly parsed";
         assert e.getID() == 2 : "ID is not correctly parsed";
         assert e.getTime() == 3 : "Time is not correctly parsed";

Modified: ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java?rev=1301607&r1=1301606&r2=1301607&view=diff
==============================================================================
--- ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java
(original)
+++ ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java
Fri Mar 16 16:03:13 2012
@@ -60,8 +60,8 @@ public class Activator extends Dependenc
     public void start() {
         try {
             String syncInterval = System.getProperty("syncinterval", "2000");
-            configureFactory("org.apache.ace.gateway.log.factory", "name", "auditlog");
-            configureFactory("org.apache.ace.gateway.log.store.factory", "name", "auditlog");
+            configureFactory("org.apache.ace.target.log.factory", "name", "auditlog");
+            configureFactory("org.apache.ace.target.log.store.factory", "name", "auditlog");
             configure("org.apache.ace.scheduler", "org.apache.ace.deployment.task.DeploymentUpdateTask",
syncInterval);
             String stopUnaffectedBundles = System.getProperty("org.apache.felix.deploymentadmin.stopunaffectedbundle",
"false");
             System.setProperty("org.apache.felix.deploymentadmin.stopunaffectedbundle", stopUnaffectedBundles);
@@ -84,12 +84,12 @@ public class Activator extends Dependenc
                     
                     boolean isFileUrl = "file".equals((new URL(url)).getProtocol());
                     
-                    configureFactory("org.apache.ace.identification.property.factory", "ma",
ma, "gatewayID", id);
+                    configureFactory("org.apache.ace.identification.property.factory", "ma",
ma, "targetID", id);
                     configureFactory("org.apache.ace.discovery.property.factory", "ma", ma,
"serverURL", url);
                     // if discovery points to the local filesystem, it's no use trying to
sync the audit log
                     // to a server (we are keeping the local log in case someone wants to
retrieve it)
                     if (!isFileUrl) {
-                        configureFactory("org.apache.ace.gateway.log.sync.factory", "ma",
ma, "name", "auditlog");
+                        configureFactory("org.apache.ace.target.log.sync.factory", "ma",
ma, "name", "auditlog");
                     }
                     configureFactory("org.apache.ace.deployment.factory", "ma", ma);
                     configure("org.apache.ace.scheduler", "ma=" + ma + ";name=auditlog",
syncInterval);
@@ -110,10 +110,10 @@ public class Activator extends Dependenc
                 String server = System.getProperty("discovery", "http://localhost:8080");
                 configure("org.apache.ace.discovery.property", "serverURL", server);
                 boolean isFileUrl = "file".equals((new URL(server)).getProtocol());
-                String targetId = System.getProperty("identification", "configuredGatewayID");
-                configure("org.apache.ace.identification.property", "gatewayID", targetId);
+                String targetId = System.getProperty("identification", "defaultTargetID");
+                configure("org.apache.ace.identification.property", "targetID", targetId);
                 if (!isFileUrl) {
-                    configureFactory("org.apache.ace.gateway.log.sync.factory", "name", "auditlog");
+                    configureFactory("org.apache.ace.target.log.sync.factory", "name", "auditlog");
                 }
                 configure("org.apache.ace.scheduler", "auditlog", syncInterval);
                 if (!m_quiet) {

Modified: ace/trunk/ace-server-log-store/src/main/java/org/apache/ace/server/log/store/impl/LogStoreImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-server-log-store/src/main/java/org/apache/ace/server/log/store/impl/LogStoreImpl.java?rev=1301607&r1=1301606&r2=1301607&view=diff
==============================================================================
--- ace/trunk/ace-server-log-store/src/main/java/org/apache/ace/server/log/store/impl/LogStoreImpl.java
(original)
+++ ace/trunk/ace-server-log-store/src/main/java/org/apache/ace/server/log/store/impl/LogStoreImpl.java
Fri Mar 16 16:03:13 2012
@@ -77,7 +77,7 @@ public class LogStoreImpl implements Log
         BufferedReader in = null;
         try {
             File log = new File(new File(m_dir,
-                    gatewayIDToFilename(descriptor.getTargetID())),
+                    targetIDToFilename(descriptor.getTargetID())),
                     String.valueOf(descriptor.getLogID()));
             if (!log.isFile()) {
                 return result;
@@ -122,17 +122,17 @@ public class LogStoreImpl implements Log
     /**
      * @see org.apache.ace.server.log.store.LogStore#getDescriptor(String, long)
      */
-    public synchronized LogDescriptor getDescriptor(String gatewayID, long logID)
+    public synchronized LogDescriptor getDescriptor(String targetID, long logID)
             throws IOException {
         Long high = m_fileToID.get(new File(new File(m_dir,
-                gatewayIDToFilename(gatewayID)), String.valueOf(logID))
+                targetIDToFilename(targetID)), String.valueOf(logID))
                 .getAbsolutePath());
         if (high != null) {
             Range r = new Range(1, high);
-            return new LogDescriptor(gatewayID, logID, new SortedRangeSet(
+            return new LogDescriptor(targetID, logID, new SortedRangeSet(
                     r.toRepresentation()));
         }
-        List<LogEvent> events = get(new LogDescriptor(gatewayID, logID,
+        List<LogEvent> events = get(new LogDescriptor(targetID, logID,
                 SortedRangeSet.FULL_SET));
 
         long[] idsArray = new long[events.size()];
@@ -140,22 +140,22 @@ public class LogStoreImpl implements Log
         for (LogEvent e : events) {
             idsArray[i++] = e.getID();
         }
-        return new LogDescriptor(gatewayID, logID, new SortedRangeSet(idsArray));
+        return new LogDescriptor(targetID, logID, new SortedRangeSet(idsArray));
     }
 
     /**
      * @see org.apache.ace.server.log.store.LogStore#getDescriptors(String)
      */
-    public List<LogDescriptor> getDescriptors(String gatewayID)
+    public List<LogDescriptor> getDescriptors(String targetID)
             throws IOException {
-        File dir = new File(m_dir, gatewayIDToFilename(gatewayID));
+        File dir = new File(m_dir, targetIDToFilename(targetID));
         List<LogDescriptor> result = new ArrayList<LogDescriptor>();
         if (!dir.isDirectory()) {
             return result;
         }
 
         for (String name : notNull(dir.list())) {
-            result.add(getDescriptor(gatewayID, Long.parseLong(name)));
+            result.add(getDescriptor(targetID, Long.parseLong(name)));
         }
 
         return result;
@@ -167,7 +167,7 @@ public class LogStoreImpl implements Log
     public List<LogDescriptor> getDescriptors() throws IOException {
         List<LogDescriptor> result = new ArrayList<LogDescriptor>();
         for (String name : notNull(m_dir.list())) {
-            result.addAll(getDescriptors(filenameToGatewayID(name)));
+            result.addAll(getDescriptors(filenameToTargetID(name)));
         }
         return result;
     }
@@ -177,9 +177,9 @@ public class LogStoreImpl implements Log
      */
     public void put(List<LogEvent> events) throws IOException {
         Map<String, Map<Long, List<LogEvent>>> sorted = sort(events);
-        for (String gatewayID : sorted.keySet()) {
-            for (Long logID : sorted.get(gatewayID).keySet()) {
-                put(gatewayID, logID, sorted.get(gatewayID).get(logID));
+        for (String targetID : sorted.keySet()) {
+            for (Long logID : sorted.get(targetID).keySet()) {
+                put(targetID, logID, sorted.get(targetID).get(logID));
             }
         }
     }
@@ -187,16 +187,16 @@ public class LogStoreImpl implements Log
     /**
      * Add a list of events to the log of the given ids.
      * 
-     * @param gatewayID
-     *            the id of the gateway to append to its log.
+     * @param targetID
+     *            the id of the target to append to its log.
      * @param logID
-     *            the id of the given gateway log.
+     *            the id of the given target log.
      * @param list
      *            a list of events to store.
      * @throws java.io.IOException
      *             in case of any error.
      */
-    protected synchronized void put(String gatewayID, Long logID,
+    protected synchronized void put(String targetID, Long logID,
             List<LogEvent> list) throws IOException {
         if ((list == null) || (list.size() == 0)) {
             // nothing to add, so return
@@ -206,7 +206,7 @@ public class LogStoreImpl implements Log
         // 1. we can append events at the end of the existing file
         // 2. we need to insert events in the existing file (meaning we have to
         // rewrite basically the whole file)
-        String file = new File(new File(m_dir, gatewayIDToFilename(gatewayID)),
+        String file = new File(new File(m_dir, targetIDToFilename(targetID)),
                 String.valueOf(logID)).getAbsolutePath();
         Long highest = m_fileToID.get(file);
         boolean cached = false;
@@ -217,7 +217,7 @@ public class LogStoreImpl implements Log
         }
         List<LogEvent> events = null;
         if (!cached) {
-            events = get(new LogDescriptor(gatewayID, logID,
+            events = get(new LogDescriptor(targetID, logID,
                     SortedRangeSet.FULL_SET));
 
             // remove duplicates first
@@ -231,7 +231,7 @@ public class LogStoreImpl implements Log
 
         PrintWriter out = null;
         try {
-            File dir = new File(m_dir, gatewayIDToFilename(gatewayID));
+            File dir = new File(m_dir, targetIDToFilename(targetID));
             if (!dir.isDirectory() && !dir.mkdirs()) {
                 throw new IOException("Unable to create backup store.");
             }
@@ -281,29 +281,29 @@ public class LogStoreImpl implements Log
 
     /**
      * Sort the given list of events into a map of maps according to the
-     * gatewayID and the logID of each event.
+     * targetID and the logID of each event.
      * 
      * @param events
      *            a list of events to sort.
-     * @return a map of maps that maps gateway ids to a map that maps log ids to
+     * @return a map of maps that maps target ids to a map that maps log ids to
      *         a list of events that have those ids.
      */
     @SuppressWarnings("boxing")
     protected Map<String, Map<Long, List<LogEvent>>> sort(List<LogEvent>
events) {
         Map<String, Map<Long, List<LogEvent>>> result = new HashMap<String,
Map<Long, List<LogEvent>>>();
         for (LogEvent event : events) {
-            Map<Long, List<LogEvent>> gateway = result
+            Map<Long, List<LogEvent>> target = result
                     .get(event.getTargetID());
 
-            if (gateway == null) {
-                gateway = new HashMap<Long, List<LogEvent>>();
-                result.put(event.getTargetID(), gateway);
+            if (target == null) {
+                target = new HashMap<Long, List<LogEvent>>();
+                result.put(event.getTargetID(), target);
             }
 
-            List<LogEvent> list = gateway.get(event.getLogID());
+            List<LogEvent> list = target.get(event.getLogID());
             if (list == null) {
                 list = new ArrayList<LogEvent>();
-                gateway.put(event.getLogID(), list);
+                target.put(event.getLogID(), list);
             }
 
             list.add(event);
@@ -322,7 +322,7 @@ public class LogStoreImpl implements Log
         return target;
     }
 
-    private static String filenameToGatewayID(String filename) {
+    private static String filenameToTargetID(String filename) {
         byte[] bytes = new byte[filename.length() / 2];
         for (int i = 0; i < (filename.length() / 2); i++) {
             String hexValue = filename.substring(i * 2, (i + 1) * 2);
@@ -339,11 +339,11 @@ public class LogStoreImpl implements Log
         return result;
     }
 
-    private static String gatewayIDToFilename(String gatewayID) {
+    private static String targetIDToFilename(String targetID) {
         StringBuilder result = new StringBuilder();
 
         try {
-            for (Byte b : gatewayID.getBytes("UTF-8")) {
+            for (Byte b : targetID.getBytes("UTF-8")) {
                 String hexValue = Integer.toHexString(b.intValue());
                 if (hexValue.length() % 2 == 0) {
                     result.append(hexValue);



Mime
View raw message