Author: zavizionov
Date: 2011-11-01 11:26:53 -0400 (Tue, 01 Nov 2011)
New Revision: 5139
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
Log:
EXOJCR-1605 Exception on console when try to suspend SearchManager
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java 2011-11-01
15:19:56 UTC (rev 5138)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java 2011-11-01
15:26:53 UTC (rev 5139)
@@ -29,6 +29,7 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import javax.jcr.RepositoryException;
@@ -174,7 +175,7 @@
{
security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
-
+
try
{
SecurityHelper.doPrivilegedExceptionAction(new
PrivilegedExceptionAction<Void>()
@@ -235,6 +236,14 @@
private void suspend() throws RepositoryException
{
List<Suspendable> components =
getComponentInstancesOfType(Suspendable.class);
+ Comparator<Suspendable> c = new Comparator<Suspendable>()
+ {
+ public int compare(Suspendable s1, Suspendable s2)
+ {
+ return s2.getPriority() - s1.getPriority();
+ };
+ };
+ Collections.sort(components, c);
for (Suspendable component : components)
{
try
@@ -256,8 +265,14 @@
private void resume() throws RepositoryException
{
List<Suspendable> components =
getComponentInstancesOfType(Suspendable.class);
- Collections.reverse(components);
-
+ Comparator<Suspendable> c = new Comparator<Suspendable>()
+ {
+ public int compare(Suspendable s1, Suspendable s2)
+ {
+ return s1.getPriority() - s2.getPriority();
+ };
+ };
+ Collections.sort(components, c);
for (Suspendable component : components)
{
try
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java 2011-11-01
15:19:56 UTC (rev 5138)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/backup/Suspendable.java 2011-11-01
15:26:53 UTC (rev 5139)
@@ -24,7 +24,23 @@
*/
public interface Suspendable
{
+
/**
+ * Priority high constant.
+ */
+ public static final int PRIORITY_HIGH = 5;
+
+ /**
+ * Priority normal constant.
+ */
+ public static final int PRIORITY_NORMAL = 0;
+
+ /**
+ * Priority low constant.
+ */
+ public static final int PRIORITY_LOW = -5;
+
+ /**
* Suspend component.
*
* @throws SuspendException if error occurred
@@ -45,4 +61,13 @@
*/
boolean isSuspended();
+ /**
+ * Priority of the component.
+ * Uses for suspend/resume comparator order.
+ * The higher number gives higher priority.
+ *
+ * @return
+ */
+ int getPriority();
+
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-11-01
15:19:56 UTC (rev 5138)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2011-11-01
15:26:53 UTC (rev 5139)
@@ -1714,4 +1714,12 @@
throw new BackupException(e);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getPriority()
+ {
+ return PRIORITY_NORMAL;
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2011-11-01
15:19:56 UTC (rev 5138)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2011-11-01
15:26:53 UTC (rev 5139)
@@ -136,4 +136,5 @@
{
return super.getStorageName() + "_" + INDEX_DIR_SUFFIX;
}
+
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2011-11-01
15:19:56 UTC (rev 5138)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2011-11-01
15:26:53 UTC (rev 5139)
@@ -3388,4 +3388,12 @@
}
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getPriority()
+ {
+ return PRIORITY_NORMAL;
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-11-01
15:19:56 UTC (rev 5138)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-11-01
15:26:53 UTC (rev 5139)
@@ -2519,6 +2519,14 @@
}
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getPriority()
+ {
+ return PRIORITY_HIGH;
+ }
/**
* Defines what we are really looking for
Show replies by date