ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1507327 - in /ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository: ./ impl/ stateful/impl/
Date Fri, 26 Jul 2013 14:26:18 GMT
Author: marrs
Date: Fri Jul 26 14:26:17 2013
New Revision: 1507327

URL: http://svn.apache.org/r1507327
Log:
Introduced a 'hold until refresh' event, that can be used by listeners to defer processing
events until either a 'login' or 'refresh' event occurs. The stateful target repository, which
has relatively expensive refresh operations, uses this to not update its internal state whil
logging in or checking out. Also, we now clean up after ourselves after logout, not holding
on to checked out workspaces beyond a session. Improved some error messages and added a toString
for repository objects.

Modified:
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryAdmin.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/Activator.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/AssociationImpl.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryAdminImpl.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java
    ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryAdmin.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryAdmin.java?rev=1507327&r1=1507326&r2=1507327&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryAdmin.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/RepositoryAdmin.java
Fri Jul 26 14:26:17 2013
@@ -30,6 +30,8 @@ public interface RepositoryAdmin
 
     public static final String TOPIC_ENTITY_ROOT = RepositoryAdmin.class.getSimpleName()
+ "/";
 
+    public static final String TOPIC_HOLDUNTILREFRESH_SUFFIX = "HOLD";
+    
     public static final String TOPIC_REFRESH_SUFFIX = "REFRESH";
     public static final String TOPIC_LOGIN_SUFFIX = "LOGIN";
     public static final String TOPIC_LOGOUT_SUFFIX = "LOGOUT";
@@ -37,6 +39,8 @@ public interface RepositoryAdmin
     public static final String TOPIC_FLUSHED_SUFFIX = "FLUSHED";
     public static final String TOPIC_ALL_SUFFIX = "*";
 
+    public static final String PRIVATE_TOPIC_HOLDUNTILREFRESH = PRIVATE_TOPIC_ROOT + TOPIC_ENTITY_ROOT
+ TOPIC_HOLDUNTILREFRESH_SUFFIX;
+    
     /**
      * Indicates a serious change to the structure of the repository, which is too complicated
to use
      * the Object's own Changed topic.

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/Activator.java?rev=1507327&r1=1507326&r2=1507327&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/Activator.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/Activator.java
Fri Jul 26 14:26:17 2013
@@ -171,6 +171,7 @@ public class Activator extends Dependenc
             Distribution2TargetAssociation.PRIVATE_TOPIC_ALL,
             TargetObject.PRIVATE_TOPIC_ALL,
             DeploymentVersionObject.PRIVATE_TOPIC_ALL,
+            RepositoryAdmin.PRIVATE_TOPIC_HOLDUNTILREFRESH, 
             RepositoryAdmin.PRIVATE_TOPIC_REFRESH, 
             RepositoryAdmin.PRIVATE_TOPIC_LOGIN 
         });

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/AssociationImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/AssociationImpl.java?rev=1507327&r1=1507326&r2=1507327&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/AssociationImpl.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/AssociationImpl.java
Fri Jul 26 14:26:17 2013
@@ -176,7 +176,7 @@ public class AssociationImpl<L extends R
                 Collections.sort(candidates, comparator);
             }
             else {
-                throw new NullPointerException("Filter '" + filter.toString() + "' has resulted
in multiple candidates, so the RepositoryObject descendents should have provide a comparator,
which they do not.");
+                throw new NullPointerException("Filter '" + filter.toString() + "' in '"
+ this + "' has resulted in multiple candidates, so the RepositoryObject descendents should
have provide a comparator, which they do not.");
             }
         }
         

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryAdminImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryAdminImpl.java?rev=1507327&r1=1507326&r2=1507327&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryAdminImpl.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryAdminImpl.java
Fri Jul 26 14:26:17 2013
@@ -268,6 +268,7 @@ public class RepositoryAdminImpl impleme
     public void checkout() throws IOException {
         synchronized (m_lock) {
             ensureLogin();
+            m_changeNotifier.notifyChanged(TOPIC_HOLDUNTILREFRESH_SUFFIX, null);
             for (PreCommitMember member : m_preCommitMembers) {
                 member.reset();
             }
@@ -375,15 +376,14 @@ public class RepositoryAdminImpl impleme
             if (m_user != null) {
                 throw new IllegalStateException("Another user is logged in.");
             }
-
             m_user = user;
             m_repositorySets = sets;
+            m_changeNotifier.notifyChanged(TOPIC_HOLDUNTILREFRESH_SUFFIX, null);
             for (RepositorySet set : m_repositorySets) {
                 set.readLocal();
                 set.loadPreferences();
             }
         }
-
         m_changeNotifier.notifyChanged(TOPIC_LOGIN_SUFFIX, null);
     }
 
@@ -410,10 +410,16 @@ public class RepositoryAdminImpl impleme
 //                set.deleteLocal();
             }
 
+            
+            unloadRepositorySet(m_user);
+            
+            
+            
             m_user = null;
 //            m_repositorySets = new RepositorySet[0];
         }
         m_changeNotifier.notifyChanged(TOPIC_LOGOUT_SUFFIX, null);
+        
         if (exception != null) {
             throw exception;
         }
@@ -568,10 +574,16 @@ public class RepositoryAdminImpl impleme
                 .setRequired(true)));
 
         Preferences prefs = m_preferences.getUserPreferences(user.getName());
+        prefs = prefs.node(m_sessionID);
         Preferences repoPrefs = getRepositoryPrefs(prefs, rsd.m_location, rsd.m_customer,
rsd.m_name);
 
         return new RepositorySet(m_changeNotifier, m_log, user, repoPrefs, repos, getCachedRepositoryFromPreferences(repo,
repoPrefs), rsd.m_name, rsd.m_writeAccess);
     }
+    
+    private void unloadRepositorySet(User user) {
+        Preferences prefs = m_preferences.getUserPreferences(user.getName());
+        prefs.remove(m_sessionID);
+    }
 
     public int getNumberWithWorkingState(Class<? extends RepositoryObject> clazz, WorkingState
state) {
         int result = 0;

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java?rev=1507327&r1=1507326&r2=1507327&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/impl/RepositoryObjectImpl.java
Fri Jul 26 14:26:17 2013
@@ -639,4 +639,18 @@ public class RepositoryObjectImpl<T exte
             return get(m_iter.nextElement());
         }
     }
+    
+    @Override
+    public String toString() {
+        StringBuilder attrs = new StringBuilder();
+        Enumeration<String> enumeration = getAttributeKeys();
+        while (enumeration.hasMoreElements()) {
+            String key = enumeration.nextElement();
+            if (attrs.length() > 0) {
+                attrs.append(',');
+            }
+            attrs.append(key + "=" + getAttribute(key));
+        }
+        return getClass().getSimpleName() + "[" + attrs.toString() + "]";
+    }
 }

Modified: ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java?rev=1507327&r1=1507326&r2=1507327&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java
(original)
+++ ace/trunk/org.apache.ace.client.repository/src/org/apache/ace/client/repository/stateful/impl/StatefulTargetRepositoryImpl.java
Fri Jul 26 14:26:17 2013
@@ -79,6 +79,7 @@ public class StatefulTargetRepositoryImp
     private Map<String, StatefulTargetObjectImpl> m_repository = new ConcurrentHashMap<String,
StatefulTargetObjectImpl>();
     private Map<String, StatefulTargetObjectImpl> m_index = new ConcurrentHashMap<String,
StatefulTargetObjectImpl>();
     private final String m_sessionID;
+    private boolean m_holdEvents = false;
 
     public StatefulTargetRepositoryImpl(String sessionID) {
         m_sessionID = sessionID;
@@ -710,55 +711,62 @@ public class StatefulTargetRepositoryImp
 
     public void handleEvent(Event event) {
         String topic = event.getTopic();
-        if (TargetObject.PRIVATE_TOPIC_ADDED.equals(topic)) {
-            synchronized (m_repository) {
-                String id = ((TargetObject) event.getProperty(RepositoryObject.EVENT_ENTITY)).getID();
-                StatefulTargetObjectImpl stoi = getStatefulTargetObject(id);
-                if (stoi == null) {
-                    createStateful(id);
-                }
-                else {
-                    stoi.updateTargetObject(true);
+        if (RepositoryAdmin.PRIVATE_TOPIC_HOLDUNTILREFRESH.equals(topic)) {
+            m_holdEvents = true;
+        }
+        if (!m_holdEvents) {
+            if (TargetObject.PRIVATE_TOPIC_ADDED.equals(topic)) {
+                synchronized (m_repository) {
+                    String id = ((TargetObject) event.getProperty(RepositoryObject.EVENT_ENTITY)).getID();
+                    StatefulTargetObjectImpl stoi = getStatefulTargetObject(id);
+                    if (stoi == null) {
+                        createStateful(id);
+                    }
+                    else {
+                        stoi.updateTargetObject(true);
+                    }
                 }
             }
-        }
-        else if (TargetObject.PRIVATE_TOPIC_REMOVED.equals(topic)) {
-            synchronized (m_repository) {
-                String id = ((TargetObject) event.getProperty(RepositoryObject.EVENT_ENTITY)).getID();
-                StatefulTargetObjectImpl stoi = getStatefulTargetObject(id);
-                // if the stateful target is already gone; we don't have to do anything...
-                if (stoi != null) {
-                    stoi.updateTargetObject(true);
+            else if (TargetObject.PRIVATE_TOPIC_REMOVED.equals(topic)) {
+                synchronized (m_repository) {
+                    String id = ((TargetObject) event.getProperty(RepositoryObject.EVENT_ENTITY)).getID();
+                    StatefulTargetObjectImpl stoi = getStatefulTargetObject(id);
+                    // if the stateful target is already gone; we don't have to do anything...
+                    if (stoi != null) {
+                        stoi.updateTargetObject(true);
+                    }
                 }
             }
-        }
-        else if (DeploymentVersionObject.PRIVATE_TOPIC_ADDED.equals(topic) || DeploymentVersionObject.PRIVATE_TOPIC_REMOVED.equals(topic))
{
-            synchronized (m_repository) {
-                DeploymentVersionObject deploymentVersionObject = ((DeploymentVersionObject)
event.getProperty(RepositoryObject.EVENT_ENTITY));
-                String id = deploymentVersionObject.getTargetID();
-                StatefulTargetObjectImpl stoi = getStatefulTargetObject(id);
-                if (stoi == null) {
-                    createStateful(id);
+            else if (DeploymentVersionObject.PRIVATE_TOPIC_ADDED.equals(topic) || DeploymentVersionObject.PRIVATE_TOPIC_REMOVED.equals(topic))
{
+                synchronized (m_repository) {
+                    DeploymentVersionObject deploymentVersionObject = ((DeploymentVersionObject)
event.getProperty(RepositoryObject.EVENT_ENTITY));
+                    String id = deploymentVersionObject.getTargetID();
+                    StatefulTargetObjectImpl stoi = getStatefulTargetObject(id);
+                    if (stoi == null) {
+                        createStateful(id);
+                    }
+                    else {
+                        stoi.updateDeploymentVersions(deploymentVersionObject);
+                    }
                 }
-                else {
-                    stoi.updateDeploymentVersions(deploymentVersionObject);
+            }
+            else {
+                // Something else has changed; however, the entire shop may have an influence
on
+                // any target, so recheck everything.
+                synchronized (m_repository) {
+                    for (StatefulTargetObjectImpl stoi : m_repository.values()) {
+                        stoi.determineStatus();
+                    }
                 }
             }
         }
-        else if (RepositoryAdmin.PRIVATE_TOPIC_LOGIN.equals(topic) || RepositoryAdmin.PRIVATE_TOPIC_REFRESH.equals(topic))
{
+        
+        if (RepositoryAdmin.PRIVATE_TOPIC_LOGIN.equals(topic) || RepositoryAdmin.PRIVATE_TOPIC_REFRESH.equals(topic))
{
+            m_holdEvents = false;
             synchronized (m_repository) {
                 populate();
             }
         }
-        else {
-            // Something else has changed; however, the entire shop may have an influence
on
-            // any target, so recheck everything.
-            synchronized (m_repository) {
-                for (StatefulTargetObjectImpl stoi : m_repository.values()) {
-                    stoi.determineStatus();
-                }
-            }
-        }
     }
 
     boolean needsNewVersion(ArtifactObject artifact, String targetID, String version) {



Mime
View raw message