You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:27:28 UTC
[sling-org-apache-sling-discovery-commons] annotated tag
org.apache.sling.discovery.commons-1.0.18 created (now 2e65048)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to annotated tag org.apache.sling.discovery.commons-1.0.18
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git.
at 2e65048 (tag)
tagging b0387f58804882faa6ef5247a4b3366c566ca3d2 (commit)
by Stefan Egli
on Tue Nov 15 12:44:54 2016 +0000
- Log -----------------------------------------------------------------
org.apache.sling.discovery.commons-1.0.18
-----------------------------------------------------------------------
This annotated tag includes the following new commits:
new b8fe30c SLING-4665 : adding patch provided by Timothee Maret, many thanks
new 7eadb24 svn:ignore updated
new 5943189 SLING-4685 : adding initial version of ViewStateManager - a shared implementation of TopologyEventListener-handling and sending of events based on activate/deactivate/changing/newView triggers - intended for use by implementors of the discovery.api (not clients of it)
new f438f9e SLING-4698 - Set parent.relativePath to empty for all modules
new 576bc0d Update svn:ignore
new f93b193 Update to Sling Parent 23
new 0035b7d set parent version to 24 and add empty relativePath where missing
new e599fa8 Update the main reactor to parent 25
new 9a31ba9 SLING-5131 : introducing ConsistencyService and an oak-discovery-lite based implementation of it - plus SLING-4697 : support for PROPERTIES_CHANGED added to ViewStateManagerImpl
new b33eee0 SLING-5131 : re-adding ViewStateManager which for some reason got removed by svn in 1707548
new bb3d20d SLING-4697 : support for PROPERTIES_CHANGED in ViewStateManagerImpl tested and thus fixed
new 0e44e3d SLING-5173 : introducing discovery.base which is the sharable parts of discovery.impl for discovery.oak - eg it includes topology connectors and base classes - plus it also includes many it-kind tests of discovery.impl
new 3d923b4 SLING-5173 : rename commons impl packages to base as they are meant for reuse by discovery.impl and discovery.oak - plus avoid using abstract component class with scr annotations - use abstract getters instead - plus some more fine-tuning of log messages - plus make discovery.impl's Config also implement DiscoveryLiteConfig - plus properly handle binds happening before activate in DiscoveryServiceImpl
new 6dd90e1 SLING-5173 : adding refactored SyncTokenOnlyConsistencyService again
new dd9150c SLING-4603 related : some fixes in class structure / syncToken handling
new cf6bb53 SLING-5173 related : EventFactory renamed to EventHelper - and introduced toShortString() for a few base view classes to shorten and make the log output more readable
new dcfc44f SLING-5173 and SLING-4603 related : more syncToken log.info - plus always doing the syncToken thingy, independent of whether any instance left or joined the cluster as otherwise this thing wont work
new 81a52c9 SLING-5173 : log.info fix
new 8b4c590 SLING-5094 / SLING-4603 related : cancel ongoing sync explicitly in order to avoid dangerous CHANGED event when changes happen during sync
new f957528 SLING-5173 : reducing visibility of isDelaying
new 732f4d6 SLING-5173 : reduce log in cancel when already done
new e88458a SLING-4603 : more aggressively clearing the idMap-cache to avoid stale entries on slingId change - plus added getSyncHistory to BaseSyncTokenConsistencyService to allow adding it to the webconsole for debug - plus some cleanup in webconsole wrt discoveryLite info
new 36ac966 SLING-5173 : introducing a more explicit chain concept for ConsistencyServices than the previous hidden/implicit one: ConsistencyServiceChain
new 1a36029 SLING-5173 : added simple implementation for findInstances
new 8d22485 SLING-5173 : added getInstance(slingId) to simplify things
new 6dd354e SLING-5173 : introducing a more explicit chain concept for ConsistencyServices than the previous hidden/implicit one: ConsistencyServiceChain
new df6d865 SLING-5173 : bugfix for leader changes: leader change was treated as a properties change - which was very bad - now it is properly treated as a TOPOLOGY_CHANGED. Note that leader change should not happen in an otherwise unchanged topology - but it can if one instance's discovery.oak bundle for example is restarted, thus getting a lower leaderElectionId. Thus discovery.commons must account for this
new 3edba1a SLING-5173 : re-added complete consistency-history after introducing splitting them and using the ConsistencyServiceChain. Probably should be refactored into something slightly nicer though
new 05027b8 SLING-5173 : minor code cleanup (duplicate logger removed)
new 2e5938f SLING-4603 : even more aggressively clearing the idMap-cache to avoid stale entries : now registering an EventHandler that listens on /var/discovery/../idMap and clears the cache on any change therein
new 11a225d SLING-4603 : minor fix to previous commit : turns out the path must be /var/xy/idMap not /var/xy/idMap/* as that would apply to children only
new 5a5f5ee SLING-5094 / SLING-5173 / SLING-4603 related : ensure that before invoking the ConsistencyService.sync no async events are still in the queue. This is achieved by enqueueing an async event too that once it gets triggered ensures that no async events are left. This mechanism ensures that before the syncToken is written, all TopologyEventListeners have received a TOPOLOGY_CHANGING - and only that guarantees that the syncToken mechanism carries a high guarantee.
new 26e1a7b SLING-5094 / SLING-5173 / SLING-4603 related : ensure that before invoking the ConsistencyService.sync no async events are still in the queue. This is achieved by enqueueing an async event too that once it gets triggered ensures that no async events are left. This mechanism ensures that before the syncToken is written, all TopologyEventListeners have received a TOPOLOGY_CHANGING - and only that guarantees that the syncToken mechanism carries a high guarantee.
new fc2a805 SLING-5191 / SLING-4603 : rename ConsistencyService to ClusterSyncService - plus making timeout/interval values for the same configurable in discovery.oak
new 032f500 SLING-5094 related : more test stability by adding a wait time of 2sec
new e5ded77 SLING-5094 / SLING-5191 / SLING-4603 : rename ConsistencyService to ClusterSyncService
new fdd2176 [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.0
new 1df7dc1 [maven-release-plugin] prepare for next development iteration
new 283f6b9 SLING-5214: include millis in testing log formats
new 5c5f5e8 SLING-5225 : increase wait times to avoid test failure on jenkins due to lower hardware speed
new 9dcf468 [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.2
new a5144bc [maven-release-plugin] prepare for next development iteration
new d71490a SLING-5256 : change in localClusterSyncTokenId should always trigger a TOPOLOGY_CHANGED - ensured by adjusting ViewStateManager.onlyDiffersInProperties and DefaultTopologyView.compareTopology accordingly including new tests for both - plus added OakDiscoveryServiceTest.testDescriptorSeqNumChange to verify that discovery.oak now properly detects otherwise-equal topologies when their sequence_number==localClusterSyncTokenId differs (unlikely to happen under normal load sit [...]
new 0f3c5c8 no-jira : fixed a log.trace message
new 3529e4f SLING-5267 : fixed testTwoNodesOneLeaving by making wait times safer, asserting for background-runnable done-state, plus added more logging in case this one is still not perfectly stable on jenkins
new 8f8aedf SLING-5282 : calling consistencyService.cancelSync(); in handleDeactivated
new 7571e2f [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.4
new 1cc2db6 [maven-release-plugin] prepare for next development iteration
new dbdcc68 SLING-5310: adding cancelDelaying to MinEventDelayHandler - plus added a testReactivate test method which checks the scenario described in this ticket. Plus also added somewhat more logging to the HeartbeatHandler to help debugging should something similar reoccur
new ca87b3d SLING-5310 : replaced waitForAsyncEvents(4sec) with Thread.sleep(4sec) then another waitForAsyncEvents(2sec) to avoid making the assertion just when the event would yet be triggered
new be1c2b7 [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.6
new 51fd2d4 [maven-release-plugin] prepare for next development iteration
new 4830188 Remove type from bundle dependencies
new ea02b02 Switch to parent pom 26
new 8cb4867 SLING-5458 : id can now be null - return null in getViewId in that case
new c664312 SLING-5458 : when clusterView.getId differs, that must result in a TOPOLOGY_CHANGING/CHANGED sequence - unlike before this fix where it just resulted in a PROPERTIES_CHANGED - which is wrong
new c29e93e [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.8
new ccce69b [maven-release-plugin] prepare for next development iteration
new 8468d76 SLING-5464 : fixed regression introduced in onlyDiffersInProperties - and added a proper JUnit test which would have avoided the problem in the first place
new 6d303d2 [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.10
new 6e713d1 [maven-release-plugin] prepare for next development iteration
new c57bb81 SLING-5494 : Discovery InstancesDiff.retained() implementation not according to API doc - Match the API with the implementation - This closes #122 of github pull request of tmaret, many thx
new 1e2a10d SLING-5592 : cancel backgroundCheck thread in deactivate for rare cases where it is still running
new e3d6546 SLING-5620 : upgrade sling.commons.scheduler dependency to 2.4.0
new 202f5b9 SLING-5621 : adding InitDelayingTopologyEventListener that came up as part of SLING-5560 to discovery.commons
new 5fdb4c5 [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.12
new a73e87d [maven-release-plugin] prepare for next development iteration
new a3da984 SLING-5598 : exclude slow running test by newly introduced Slow junit category - to run them nevertheless use -PincludeSlowTests
new da23f5b use org.apache.sling.commons.testing 2.0.26
new 188fecc use stable releases (Jackrabbit and Oak)
new 37e5450 SLING-5995 : changing IdMapService from being an OSGi EventListener to a Sling ResourceChangeListener
new 31f4a00 [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.14
new 94f722a [maven-release-plugin] prepare for next development iteration
new 611306b fix build error: switch sling API to 2.11 because 2.10 was never released
new 21a7966 [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.16
new 5e52b0c [maven-release-plugin] prepare for next development iteration
new cc9361e SLING-5231 : remove getAdministrativeResourceResolver from discovery components : merged patches from Carsten
new 32ef365 [maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.18
new b0387f5 [maven-release-plugin] copy for tag org.apache.sling.discovery.commons-1.0.18
The 79 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-org-apache-sling-discovery-commons] 03/04:
[maven-release-plugin] prepare release
org.apache.sling.discovery.commons-1.0.18
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.discovery.commons-1.0.18
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git
commit 32ef3650d952df021bfdd1dc6246fcf627877a15
Author: Stefan Egli <st...@apache.org>
AuthorDate: Tue Nov 15 12:44:40 2016 +0000
[maven-release-plugin] prepare release org.apache.sling.discovery.commons-1.0.18
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons@1769805 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index bf7db40..ae929d5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,15 +29,15 @@
<artifactId>org.apache.sling.discovery.commons</artifactId>
<packaging>bundle</packaging>
- <version>1.0.17-SNAPSHOT</version>
+ <version>1.0.18</version>
<name>Apache Sling Discovery Commons</name>
<description>Common services related to Sling Discovery</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/commons</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.commons-1.0.18</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.commons-1.0.18</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.discovery.commons-1.0.18</url>
</scm>
<properties>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-discovery-commons] 02/04: SLING-5231 :
remove getAdministrativeResourceResolver from discovery components : merged
patches from Carsten
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.discovery.commons-1.0.18
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git
commit cc9361e9d9aaeba819f57b01f88cb0d58d553d68
Author: Stefan Egli <st...@apache.org>
AuthorDate: Tue Nov 15 12:38:35 2016 +0000
SLING-5231 : remove getAdministrativeResourceResolver from discovery components : merged patches from Carsten
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons@1769802 13f79535-47bb-0310-9956-ffa450edef68
---
.../commons/providers/spi/base/IdMapService.java | 33 +++++----
.../spi/base/OakBacklogClusterSyncService.java | 46 ++++++------
.../providers/spi/base/SyncTokenService.java | 26 +++----
.../commons/providers/base/TestHelper.java | 6 +-
.../providers/base/TestMinEventDelayHandler.java | 32 ++++-----
.../providers/base/TestViewStateManager.java | 83 +++++++++++-----------
.../providers/spi/base/DescriptorHelper.java | 9 ++-
.../providers/spi/base/MockedResourceResolver.java | 38 +++++++++-
.../providers/spi/base/RepositoryTestHelper.java | 14 ++--
9 files changed, 160 insertions(+), 127 deletions(-)
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java
index e171738..4f1dbfb 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/IdMapService.java
@@ -48,7 +48,6 @@ import org.apache.sling.settings.SlingSettingsService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.event.Event;
/**
* The IdMapService is responsible for storing a slingId-clusterNodeId
@@ -67,9 +66,9 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
@Reference
private DiscoveryLiteConfig commonsConfig;
-
+
private boolean initialized = false;
-
+
private String slingId;
private long me;
@@ -100,9 +99,9 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
protected void activate(BundleContext bundleContext) {
this.bundleContext = bundleContext;
registerEventHandler();
-
+
startBackgroundCheck("IdMapService-initializer", new BackgroundCheck() {
-
+
@Override
public boolean check() {
try {
@@ -114,7 +113,7 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
}
}, null, -1, 1000 /* = 1sec interval */);
}
-
+
@Deactivate
protected void deactivate() {
if (eventHandlerRegistration != null) {
@@ -124,7 +123,7 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
// SLING-5592: cancel the potentially running background thread
cancelPreviousBackgroundCheck();
}
-
+
private void registerEventHandler() {
if (bundleContext == null) {
logger.info("registerEventHandler: bundleContext is null - cannot register");
@@ -146,16 +145,16 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
/** Get or create a ResourceResolver **/
private ResourceResolver getResourceResolver() throws LoginException {
- return resourceResolverFactory.getAdministrativeResourceResolver(null);
+ return resourceResolverFactory.getServiceResourceResolver(null);
}
-
+
public synchronized long getMyId() {
if (!initialized) {
return -1;
}
return me;
}
-
+
/** for testing only **/
public synchronized boolean waitForInit(long timeout) {
long start = System.currentTimeMillis();
@@ -176,7 +175,7 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
}
return initialized;
}
-
+
public synchronized boolean isInitialized() {
return initialized;
}
@@ -189,7 +188,7 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
ResourceResolver resourceResolver = null;
try{
resourceResolver = getResourceResolver();
- DiscoveryLiteDescriptor descriptor =
+ DiscoveryLiteDescriptor descriptor =
DiscoveryLiteDescriptor.getDescriptorFrom(resourceResolver);
long me = descriptor.getMyId();
final Resource resource = ResourceHelper.getOrCreateResource(resourceResolver, getIdMapPath());
@@ -242,9 +241,9 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
resourceResolver.close();
}
}
-
+
}
-
+
public synchronized void clearCache() {
if (!idMapCache.isEmpty()) {
logger.debug("clearCache: clearing idmap cache");
@@ -265,7 +264,7 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
// force a cache invalidation).
// we can either rely on observation - or combine that with
// an invalidation of once per minute
- // (note that this means we'll be reading
+ // (note that this means we'll be reading
// /var/discovery/oak/idMap once per minute - but that sounds
// perfectly fine)
clearCache();
@@ -294,10 +293,10 @@ public class IdMapService extends AbstractServiceWithBackgroundCheck implements
logger.info("toSlingId: mapping for "+oldEntry.getKey()+" to "+oldEntry.getValue()+" disappeared.");
}
}
-
+
return idMapCache.get(clusterNodeId);
}
-
+
private Map<Integer, String> readIdMap(ResourceResolver resourceResolver) throws PersistenceException {
Resource resource = ResourceHelper.getOrCreateResource(resourceResolver, getIdMapPath());
ValueMap idmapValueMap = resource.adaptTo(ValueMap.class);
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
index 8fbe1cb..be76048 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
@@ -50,10 +50,10 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
HAS_BACKLOG /* when oak's discovery lite descriptor indicated that there is still some backlog */,
NO_BACKLOG /* when oak's discovery lite descriptor declared we're backlog-free now */
}
-
+
@Reference
private IdMapService idMapService;
-
+
@Reference
protected DiscoveryLiteConfig commonsConfig;
@@ -64,7 +64,7 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
protected SlingSettingsService settingsService;
private ClusterSyncHistory consistencyHistory = new ClusterSyncHistory();
-
+
public static OakBacklogClusterSyncService testConstructorAndActivate(
final DiscoveryLiteConfig commonsConfig,
final IdMapService idMapService,
@@ -74,7 +74,7 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
service.activate();
return service;
}
-
+
/**
* for testing only!
* @param resourceResolverFactory
@@ -82,7 +82,7 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
* @param syncTokenTimeoutMillis timeout value in millis after which the
* sync-token process is cancelled - or -1 if no timeout should be used there
* @param backlogWaitTimeoutMillis timeout value in millis after which
- * the waiting-while-backlog should be cancelled - or -1 if no timeout should be
+ * the waiting-while-backlog should be cancelled - or -1 if no timeout should be
* used there
* @throws LoginException when the login for initialization failed
* @throws JSONException when the descriptor wasn't proper json at init time
@@ -108,26 +108,26 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
service.settingsService = settingsService;
return service;
}
-
+
@Activate
protected void activate() {
this.slingId = getSettingsService().getSlingId();
logger.info("activate: activated with slingId="+slingId);
}
-
+
public void setConsistencyHistory(ClusterSyncHistory consistencyHistory) {
this.consistencyHistory = consistencyHistory;
}
-
+
public ClusterSyncHistory getConsistencyHistory() {
return consistencyHistory;
}
-
+
/** Get or create a ResourceResolver **/
protected ResourceResolver getResourceResolver() throws LoginException {
- return resourceResolverFactory.getAdministrativeResourceResolver(null);
+ return resourceResolverFactory.getServiceResourceResolver(null);
}
-
+
@Override
public void cancelSync() {
cancelPreviousBackgroundCheck();
@@ -144,10 +144,10 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
}
private void waitWhileBacklog(final BaseTopologyView view, final Runnable runnable) {
- // start backgroundChecking until the backlogStatus
+ // start backgroundChecking until the backlogStatus
// is NO_BACKLOG
startBackgroundCheck("OakBacklogClusterSyncService-backlog-waiting", new BackgroundCheck() {
-
+
@Override
public boolean check() {
try {
@@ -176,37 +176,37 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
}
}, runnable, getCommonsConfig().getClusterSyncServiceTimeoutMillis(), getCommonsConfig().getClusterSyncServiceIntervalMillis());
}
-
+
private BacklogStatus getBacklogStatus(BaseTopologyView view) {
logger.trace("getBacklogStatus: start");
ResourceResolver resourceResolver = null;
try{
resourceResolver = getResourceResolver();
- DiscoveryLiteDescriptor descriptor =
+ DiscoveryLiteDescriptor descriptor =
DiscoveryLiteDescriptor.getDescriptorFrom(resourceResolver);
// backlog-free means:
- // 1) 'deactivating' must be empty
+ // 1) 'deactivating' must be empty
// (otherwise we indeed have a backlog)
// 2) all active ids of the descriptor must have a mapping to slingIds
// (otherwise the init failed or is pending for some instance(s))
- // 3) all 'active' instances must be in the view
- // (otherwise discovery lite might not yet consider
+ // 3) all 'active' instances must be in the view
+ // (otherwise discovery lite might not yet consider
// an instance dead but discovery-service does)
// instead what is fine from a backlog point of view
// * instances in the view but listed as 'inactive'
// (this might be the case for just-started instances)
// * instances in the view but not contained in the descriptor at all
// (this might be the case for just-started instances)
-
+
int[] activeIds = descriptor.getActiveIds();
int[] deactivatingIds = descriptor.getDeactivatingIds();
// we're not worried about 'inactive' ones - as that could
// be a larger list filled with legacy entries too
- // plus once the instance is inactive there's no need to
+ // plus once the instance is inactive there's no need to
// check anything further - that one is then backlog-free
-
- // 1) 'deactivating' must be empty
+
+ // 1) 'deactivating' must be empty
if (deactivatingIds.length!=0) {
logger.info("getBacklogStatus: there are deactivating instances: "+Arrays.toString(deactivatingIds));
return BacklogStatus.HAS_BACKLOG;
@@ -217,7 +217,7 @@ public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundC
for (InstanceDescription instance : cluster.getInstances()) {
slingIds.add(instance.getSlingId());
}
-
+
for(int i=0; i<activeIds.length; i++) {
int activeId = activeIds[i];
String slingId = idMapService.toSlingId(activeId, resourceResolver);
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
index 23ac970..dd57256 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
@@ -68,7 +68,7 @@ public class SyncTokenService extends AbstractServiceWithBackgroundCheck impleme
service.activate();
return service;
}
-
+
public static SyncTokenService testConstructor(
DiscoveryLiteConfig commonsConfig,
ResourceResolverFactory resourceResolverFactory,
@@ -94,20 +94,20 @@ public class SyncTokenService extends AbstractServiceWithBackgroundCheck impleme
this.slingId = settingsService.getSlingId();
logger.info("activate: activated with slingId="+slingId);
}
-
+
public void setConsistencyHistory(ClusterSyncHistory consistencyHistory) {
this.clusterSyncHistory = consistencyHistory;
}
-
+
public ClusterSyncHistory getClusterSyncHistory() {
return clusterSyncHistory;
}
-
+
/** Get or create a ResourceResolver **/
protected ResourceResolver getResourceResolver() throws LoginException {
- return resourceResolverFactory.getAdministrativeResourceResolver(null);
+ return resourceResolverFactory.getServiceResourceResolver(null);
}
-
+
@Override
public void cancelSync() {
cancelPreviousBackgroundCheck();
@@ -124,9 +124,9 @@ public class SyncTokenService extends AbstractServiceWithBackgroundCheck impleme
}
protected void syncToken(final BaseTopologyView view, final Runnable callback) {
-
+
startBackgroundCheck("SyncTokenService", new BackgroundCheck() {
-
+
@Override
public boolean check() {
// 1) first storing my syncToken
@@ -134,12 +134,12 @@ public class SyncTokenService extends AbstractServiceWithBackgroundCheck impleme
if (!storeMySyncToken(localClusterSyncTokenId)) {
// if anything goes wrong above, then this will mean for the others
// that they will have to wait until the timeout hits
-
+
// so to try to avoid this, retry storing my sync token later:
clusterSyncHistory.addHistoryEntry(view, "storing my syncToken ("+localClusterSyncTokenId+")");
return false;
}
-
+
// 2) then check if all others have done the same already
return seenAllSyncTokens(view);
}
@@ -200,7 +200,7 @@ public class SyncTokenService extends AbstractServiceWithBackgroundCheck impleme
Resource resource = ResourceHelper.getOrCreateResource(resourceResolver, getSyncTokenPath());
ValueMap syncTokens = resource.adaptTo(ValueMap.class);
String syncToken = view.getLocalClusterSyncTokenId();
-
+
boolean success = true;
StringBuffer historyEntry = new StringBuffer();
for (InstanceDescription instance : view.getLocalInstance().getClusterView().getInstances()) {
@@ -232,7 +232,7 @@ public class SyncTokenService extends AbstractServiceWithBackgroundCheck impleme
} else {
clusterSyncHistory.addHistoryEntry(view, "seen all syncTokens");
}
-
+
resourceResolver.commit();
logger.info("seenAllSyncTokens: seen all syncTokens!");
return true;
@@ -249,5 +249,5 @@ public class SyncTokenService extends AbstractServiceWithBackgroundCheck impleme
}
}
}
-
+
}
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestHelper.java b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestHelper.java
index 72ab0d2..a1f13b2 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestHelper.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestHelper.java
@@ -19,7 +19,6 @@
package org.apache.sling.discovery.commons.providers.base;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
@@ -33,7 +32,6 @@ import org.apache.sling.discovery.commons.providers.DefaultClusterView;
import org.apache.sling.discovery.commons.providers.DefaultInstanceDescription;
import org.apache.sling.discovery.commons.providers.DummyTopologyView;
import org.apache.sling.discovery.commons.providers.EventHelper;
-import org.apache.sling.discovery.commons.providers.base.ViewStateManagerImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,7 +76,7 @@ public class TestHelper {
if (!mgr.getAsyncEventSender().hasInFlightEvent()) {
return;
}
-
+
// sleep outside of synchronized to keep test-influence
// to a minimum
try {
@@ -96,7 +94,7 @@ public class TestHelper {
}
/** does couple loops randomly calling handleChanging() (or not) and then handleNewView().
- * Note: random is passed to allow customizing and not hardcoding this method to a particular random
+ * Note: random is passed to allow customizing and not hardcoding this method to a particular random
* @throws InterruptedException **/
public static void randomEventLoop(ViewStateManagerImpl mgr, DummyDiscoveryService sds, int loopSize, int delayInMillis, final Random random, DummyListener... listeners) throws InterruptedException {
for(int i=0; i<loopSize; i++) {
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java
index eabc85f..e09aaf6 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java
@@ -28,7 +28,7 @@ import java.util.UUID;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
+import org.apache.log4j.spi.RootLogger;
import org.apache.sling.commons.testing.junit.categories.Slow;
import org.apache.sling.discovery.commons.providers.BaseTopologyView;
import org.apache.sling.discovery.commons.providers.DefaultClusterView;
@@ -38,7 +38,6 @@ import org.apache.sling.discovery.commons.providers.base.ViewStateManagerImpl;
import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
@@ -49,9 +48,9 @@ public class TestMinEventDelayHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private ViewStateManagerImpl mgr;
-
+
private Random defaultRandom;
-
+
private DummyDiscoveryService sds;
private Level logLevel;
@@ -61,11 +60,12 @@ public class TestMinEventDelayHandler {
@Before
public void setup() throws Exception {
mgr = new ViewStateManagerImpl(new ReentrantLock(), new ClusterSyncService() {
-
+
+ @Override
public void sync(BaseTopologyView view, Runnable callback) {
callback.run();
}
-
+
@Override
public void cancelSync() {
// nothing to cancel, we're auto-run
@@ -77,7 +77,7 @@ public class TestMinEventDelayHandler {
sds = new DummyDiscoveryService();
mgr.installMinEventDelayHandler(sds, scheduler, 1);
- final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+ final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
logLevel = discoveryLogger.getLevel();
discoveryLogger.setLevel(Level.INFO); // changed from Level.DEBUG
}
@@ -86,7 +86,7 @@ public class TestMinEventDelayHandler {
public void teardown() throws Exception {
mgr = null;
defaultRandom= null;
- final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+ final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
discoveryLogger.setLevel(logLevel);
}
@@ -103,9 +103,9 @@ public class TestMinEventDelayHandler {
mgr.handleActivated();
TestHelper.assertNoEvents(listener);
final DummyTopologyView view1 = new DummyTopologyView().addInstance();
- final DummyTopologyView view2 = DummyTopologyView.clone(view1).addInstance(UUID.randomUUID().toString(),
+ final DummyTopologyView view2 = DummyTopologyView.clone(view1).addInstance(UUID.randomUUID().toString(),
(DefaultClusterView) view1.getLocalInstance().getClusterView(), false, false);
- final DummyTopologyView view3 = DummyTopologyView.clone(view1).addInstance(UUID.randomUUID().toString(),
+ final DummyTopologyView view3 = DummyTopologyView.clone(view1).addInstance(UUID.randomUUID().toString(),
(DefaultClusterView) view1.getLocalInstance().getClusterView(), false, false);
logger.info("testReactivate: calling handleNewView...");
mgr.handleNewView(view1);
@@ -125,7 +125,7 @@ public class TestMinEventDelayHandler {
assertEquals(0, mgr.waitForAsyncEvents(2000));
logger.info("testReactivate: asserting CHANGED event");
TestHelper.assertEvents(mgr, listener, EventHelper.newChangedEvent(view1, view2));
-
+
// now do the above again, but this time do a handleDeactivated before receiving another changed event
logger.info("testReactivate: calling handleChanging...");
mgr.handleChanging();
@@ -135,21 +135,21 @@ public class TestMinEventDelayHandler {
TestHelper.assertNoEvents(listener);
// make sure the MinEventDelayHandler finds a topology when coming back from the delaying, so:
sds.setTopoology(view3);
-
+
logger.info("testReactivate: doing handleDeactivated");
final AsyncEventSender asyncEventSender = mgr.getAsyncEventSender();
Field field = mgr.getClass().getDeclaredField("minEventDelayHandler");
field.setAccessible(true);
MinEventDelayHandler minEventDelayHandler = (MinEventDelayHandler) field.get(mgr);
assertNotNull(minEventDelayHandler);
-
+
// marking view3 as not current
view3.setNotCurrent();
sds.setTopoology(view3);
-
+
mgr.handleDeactivated();
TestHelper.assertNoEvents(listener);
-
+
logger.info("testReactivate: now waiting 5 sec to make sure the MinEventDelayHandler would be finished");
TestHelper.assertNoEvents(listener);
Thread.sleep(5000);
@@ -214,7 +214,7 @@ public class TestMinEventDelayHandler {
Thread.sleep(1000);
}
}
-
+
@Test
public void testLongMinDelay() throws Exception {
mgr.installMinEventDelayHandler(sds, scheduler, 5);
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java
index 34cfa93..3b29202 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java
@@ -31,8 +31,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-import org.apache.sling.commons.testing.junit.categories.Slow;
+import org.apache.log4j.spi.RootLogger;
import org.apache.sling.discovery.ClusterView;
import org.apache.sling.discovery.DiscoveryService;
import org.apache.sling.discovery.InstanceDescription;
@@ -47,7 +46,6 @@ import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.junit.experimental.categories.Category;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,7 +62,8 @@ public class TestViewStateManager {
this.lock = lock;
this.semaphore = semaphore;
}
-
+
+ @Override
public void sync(BaseTopologyView view, Runnable callback) {
try {
lock.unlock();
@@ -97,22 +96,23 @@ public class TestViewStateManager {
@Before
public void setup() throws Exception {
mgr = new ViewStateManagerImpl(new ReentrantLock(), new ClusterSyncService() {
-
+
+ @Override
public void sync(BaseTopologyView view, Runnable callback) {
callback.run();
}
-
+
@Override
public void cancelSync() {
// nothing to cancel, we're auto-run
}
});
defaultRandom = new Random(1234123412); // I want randomness yes, but deterministic, for some methods at least
- final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+ final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
logLevel = discoveryLogger.getLevel();
discoveryLogger.setLevel(Level.INFO);
}
-
+
@After
public void teardown() throws Exception {
if (mgr != null) {
@@ -121,7 +121,7 @@ public class TestViewStateManager {
}
mgr = null;
defaultRandom= null;
- final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+ final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
discoveryLogger.setLevel(logLevel);
}
@@ -172,7 +172,7 @@ public class TestViewStateManager {
mgr.bind(listener); // we should be generous and allow duplicate registration
assertTrue(mgr.unbind(listener));
assertFalse(mgr.unbind(listener));
-
+
mgr.handleActivated();
assertFalse(mgr.unbind(listener));
mgr.bind(listener);
@@ -180,7 +180,7 @@ public class TestViewStateManager {
assertTrue(mgr.unbind(listener));
assertFalse(mgr.unbind(listener));
}
-
+
@Test
public void testBindActivateChangingChanged() throws Exception {
final DummyListener listener = new DummyListener();
@@ -195,7 +195,7 @@ public class TestViewStateManager {
assertEvents(listener, EventHelper.newInitEvent(view));
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testBindChangingActivateChanged() throws Exception {
final DummyListener listener = new DummyListener();
@@ -210,7 +210,7 @@ public class TestViewStateManager {
assertEvents(listener, EventHelper.newInitEvent(view));
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testBindChangingChangedActivate() throws Exception {
final DummyListener listener = new DummyListener();
@@ -225,7 +225,7 @@ public class TestViewStateManager {
assertEvents(listener, EventHelper.newInitEvent(view));
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testBindChangingChangedChangingActivate() throws Exception {
final DummyListener listener = new DummyListener();
@@ -245,7 +245,7 @@ public class TestViewStateManager {
assertEvents(listener, EventHelper.newInitEvent(view2));
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testBindChangedChangingActivate() throws Exception {
final DummyListener listener = new DummyListener();
@@ -263,18 +263,19 @@ public class TestViewStateManager {
assertEvents(listener, EventHelper.newInitEvent(view2));
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testCancelSync() throws Exception {
final List<Runnable> syncCallbacks = new LinkedList<Runnable>();
mgr = new ViewStateManagerImpl(new ReentrantLock(), new ClusterSyncService() {
-
+
+ @Override
public void sync(BaseTopologyView view, Runnable callback) {
synchronized(syncCallbacks) {
syncCallbacks.add(callback);
}
}
-
+
@Override
public void cancelSync() {
synchronized(syncCallbacks) {
@@ -295,7 +296,7 @@ public class TestViewStateManager {
}
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
- final BaseTopologyView view2 = TestHelper.newView(true, id1, id1, id1, id2);
+ final BaseTopologyView view2 = TestHelper.newView(true, id1, id1, id1, id2);
mgr.handleNewView(view2);
assertEquals(0, mgr.waitForAsyncEvents(1000));
TestHelper.assertNoEvents(listener);
@@ -307,7 +308,7 @@ public class TestViewStateManager {
assertEquals(0, mgr.waitForAsyncEvents(1000));
assertEvents(listener, EventHelper.newInitEvent(view2));
}
-
+
@Test
public void testActivateBindChangingChanged() throws Exception {
final DummyListener listener = new DummyListener();
@@ -332,7 +333,7 @@ public class TestViewStateManager {
mgr.bind(listener);
mgr.handleChanging();
DummyTopologyView oldView = new DummyTopologyView().addInstance();
- DefaultInstanceDescription localInstance =
+ DefaultInstanceDescription localInstance =
(DefaultInstanceDescription) oldView.getLocalInstance();
localInstance.setProperty("foo", "bar1");
mgr.handleNewView(oldView);
@@ -381,12 +382,12 @@ public class TestViewStateManager {
assertEvents(listener, EventHelper.newInitEvent(view));
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testBindActivateBindChangingChanged() throws Exception {
final DummyListener listener1 = new DummyListener();
final DummyListener listener2 = new DummyListener();
-
+
mgr.bind(listener1);
TestHelper.assertNoEvents(listener1);
mgr.handleActivated();
@@ -401,7 +402,7 @@ public class TestViewStateManager {
mgr.handleNewView(view);
assertEvents(listener1, EventHelper.newInitEvent(view));
assertEvents(listener2, EventHelper.newInitEvent(view));
-
+
randomEventLoop(defaultRandom, listener1, listener2);
}
@@ -409,7 +410,7 @@ public class TestViewStateManager {
public void testBindActivateChangingBindChanged() throws Exception {
final DummyListener listener1 = new DummyListener();
final DummyListener listener2 = new DummyListener();
-
+
mgr.bind(listener1);
TestHelper.assertNoEvents(listener1);
mgr.handleActivated();
@@ -426,7 +427,7 @@ public class TestViewStateManager {
randomEventLoop(defaultRandom, listener1, listener2);
}
-
+
@Test
public void testActivateBindChangingDuplicateHandleNewView() throws Exception {
final DummyListener listener = new DummyListener();
@@ -440,7 +441,7 @@ public class TestViewStateManager {
TestHelper.assertNoEvents(listener);
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testActivateBindChangingChangedBindDuplicateHandleNewView() throws Exception {
final DummyListener listener1 = new DummyListener();
@@ -450,7 +451,7 @@ public class TestViewStateManager {
final DummyTopologyView view = new DummyTopologyView().addInstance();
mgr.handleNewView(view);
assertEvents(listener1, EventHelper.newInitEvent(view));
-
+
final DummyListener listener2 = new DummyListener();
mgr.bind(listener2);
mgr.handleNewView(DummyTopologyView.clone(view));
@@ -458,7 +459,7 @@ public class TestViewStateManager {
assertEvents(listener2, EventHelper.newInitEvent(view));
randomEventLoop(defaultRandom, listener1, listener2);
}
-
+
@Test
public void testActivateChangedBindDuplicateHandleNewView() throws Exception {
final DummyListener listener = new DummyListener();
@@ -473,7 +474,7 @@ public class TestViewStateManager {
TestHelper.assertNoEvents(listener);
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testBindActivateChangedChanged() throws Exception {
final DummyListener listener = new DummyListener();
@@ -491,7 +492,7 @@ public class TestViewStateManager {
assertEvents(listener, EventHelper.newChangingEvent(view1), EventHelper.newChangedEvent(view1, view2));
randomEventLoop(defaultRandom, listener);
}
-
+
@Test
public void testBindActivateChangedDeactivateChangingActivateChanged() throws Exception {
final DummyListener listener = new DummyListener();
@@ -560,11 +561,11 @@ public class TestViewStateManager {
mgr.handleNewView(view2);
assertEvents(listener, EventHelper.newInitEvent(view2));
}
-
+
@Test
public void testClusterSyncService_noConcurrency() throws Exception {
- final org.apache.log4j.Logger commonsLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery.commons.providers");
- final org.apache.log4j.Level logLevel = commonsLogger.getLevel();
+ final org.apache.log4j.Logger commonsLogger = RootLogger.getLogger("org.apache.sling.discovery.commons.providers");
+// final org.apache.log4j.Level logLevel = commonsLogger.getLevel();
commonsLogger.setLevel(Level.INFO); // change here to DEBUG in case of issues with this test
final Semaphore serviceSemaphore = new Semaphore(0);
final ReentrantLock lock = new ReentrantLock();
@@ -584,10 +585,11 @@ public class TestViewStateManager {
.addInstance(slingId2, cluster, false, false);
async(new Runnable() {
+ @Override
public void run() {
mgr.handleNewView(view1);
}
-
+
});
Thread.sleep(1000);
TestHelper.assertNoEvents(listener);
@@ -600,10 +602,11 @@ public class TestViewStateManager {
view2.removeInstance(slingId2);
async(new Runnable() {
+ @Override
public void run() {
mgr.handleNewView(view2);
}
-
+
});
logger.debug("run: waiting for 1sec");
Thread.sleep(1000);
@@ -624,7 +627,7 @@ public class TestViewStateManager {
@Test
public void testOnlyDiffersInProperties() throws Exception {
- final org.apache.log4j.Logger discoveryLogger = LogManager.getRootLogger().getLogger("org.apache.sling.discovery");
+ final org.apache.log4j.Logger discoveryLogger = RootLogger.getLogger("org.apache.sling.discovery");
discoveryLogger.setLevel(Level.INFO); // changed from Level.DEBUG
logger.info("testOnlyDiffersInProperties: start");
final String slingId1 = UUID.randomUUID().toString();
@@ -639,7 +642,7 @@ public class TestViewStateManager {
final DummyTopologyView view2 = DummyTopologyView.clone(view1).removeInstance(slingId2);
final DummyTopologyView view3 = DummyTopologyView.clone(view1).removeInstance(slingId2).removeInstance(slingId3);
DummyTopologyView view1Cloned = DummyTopologyView.clone(view1);
-
+
logger.info("testOnlyDiffersInProperties: handleNewView(view1)");
mgr.handleNewView(view1);
logger.info("testOnlyDiffersInProperties: handleActivated()");
@@ -671,7 +674,7 @@ public class TestViewStateManager {
i4_1.setProperty("a", "b");
logger.info("testOnlyDiffersInProperties: onlyDiffersInProperties(view4)");
assertTrue(mgr.onlyDiffersInProperties(view4));
-
+
DefaultInstanceDescription i5_1 = (DefaultInstanceDescription) view5.getInstance(slingId1);
i5_1.setProperty("a", "b");
logger.info("testOnlyDiffersInProperties: onlyDiffersInProperties(view5)");
@@ -701,7 +704,7 @@ public class TestViewStateManager {
view6.setId(originalId);
logger.info("testOnlyDiffersInProperties: onlyDiffersInProperties(view6) [5]");
assertTrue(mgr.onlyDiffersInProperties(view6));
-
+
// hack: we're modifying the view *in the ViewStateManagerImpl* here!!:
view4.setId(null);
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/DescriptorHelper.java b/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/DescriptorHelper.java
index 5fc6cae..3de193f 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/DescriptorHelper.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/DescriptorHelper.java
@@ -30,24 +30,23 @@ import org.apache.jackrabbit.commons.SimpleValueFactory;
import org.apache.jackrabbit.oak.util.GenericDescriptors;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
-import org.apache.sling.discovery.commons.providers.spi.base.DiscoveryLiteDescriptor;
public class DescriptorHelper {
public static void setDiscoveryLiteDescriptor(ResourceResolverFactory factory, DiscoveryLiteDescriptorBuilder builder) throws Exception {
setDescriptor(factory, DiscoveryLiteDescriptor.OAK_DISCOVERYLITE_CLUSTERVIEW, builder.asJson());
}
-
+
public static void setDescriptor(ResourceResolverFactory factory, String key,
String value) throws Exception {
- ResourceResolver resourceResolver = factory.getAdministrativeResourceResolver(null);
+ ResourceResolver resourceResolver = factory.getServiceResourceResolver(null);
try{
Session session = resourceResolver.adaptTo(Session.class);
if (session == null) {
return;
}
Repository repo = session.getRepository();
-
+
//<hack>
// Method setDescriptorMethod = repo.getClass().
// getDeclaredMethod("setDescriptor", String.class, String.class);
@@ -67,7 +66,7 @@ public class DescriptorHelper {
descriptors.put(key, valueFactory.createValue(value), true, true);
}
//</hack>
-
+
//<verify-hack>
assertEquals(value, repo.getDescriptor(key));
//</verify-hack>
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/MockedResourceResolver.java b/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/MockedResourceResolver.java
index 16a9c38..2a556d2 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/MockedResourceResolver.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/MockedResourceResolver.java
@@ -96,6 +96,7 @@ public class MockedResourceResolver implements ResourceResolver {
}
+ @Override
@SuppressWarnings("unchecked")
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
if (type.equals(Session.class)) {
@@ -110,27 +111,33 @@ public class MockedResourceResolver implements ResourceResolver {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public Resource resolve(HttpServletRequest request, String absPath) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public Resource resolve(String absPath) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
@Deprecated
public Resource resolve(HttpServletRequest request) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public String map(String resourcePath) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public String map(HttpServletRequest request, String resourcePath) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public Resource getResource(String path) {
Session session;
try {
@@ -144,6 +151,7 @@ public class MockedResourceResolver implements ResourceResolver {
return new MockedResource(this, path, "nt:unstructured");
}
+ @Override
public Resource getResource(Resource base, String path) {
if (base.getPath().equals("/")) {
return getResource("/" + path);
@@ -152,20 +160,24 @@ public class MockedResourceResolver implements ResourceResolver {
}
}
+ @Override
public String[] getSearchPath() {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public Iterator<Resource> listChildren(Resource parent) {
try {
Node node = parent.adaptTo(Node.class);
final NodeIterator nodes = node.getNodes();
return new Iterator<Resource>() {
+ @Override
public void remove() {
throw new UnsupportedOperationException();
}
+ @Override
public Resource next() {
Node next = nodes.nextNode();
try {
@@ -177,6 +189,7 @@ public class MockedResourceResolver implements ResourceResolver {
}
}
+ @Override
public boolean hasNext() {
return nodes.hasNext();
}
@@ -186,28 +199,34 @@ public class MockedResourceResolver implements ResourceResolver {
}
}
+ @Override
public Iterable<Resource> getChildren(Resource parent) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public Iterator<Resource> findResources(String query, String language) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public Iterator<Map<String, Object>> queryResources(String query,
String language) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public ResourceResolver clone(Map<String, Object> authenticationInfo)
throws LoginException {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public boolean isLive() {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public void close() {
Iterator<MockedResource> it = resources.iterator();
while (it.hasNext()) {
@@ -226,18 +245,22 @@ public class MockedResourceResolver implements ResourceResolver {
resources.add(mockedResource);
}
+ @Override
public String getUserID() {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public Iterator<String> getAttributeNames() {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public Object getAttribute(String name) {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public void delete(Resource resource) throws PersistenceException {
if (resources.contains(resource)) {
resources.remove(resource);
@@ -252,6 +275,7 @@ public class MockedResourceResolver implements ResourceResolver {
}
}
+ @Override
public Resource create(Resource parent, String name,
Map<String, Object> properties) throws PersistenceException {
final Node parentNode = parent.adaptTo(Node.class);
@@ -286,6 +310,7 @@ public class MockedResourceResolver implements ResourceResolver {
}
}
+ @Override
public void revert() {
try {
this.session.refresh(false);
@@ -294,6 +319,7 @@ public class MockedResourceResolver implements ResourceResolver {
}
}
+ @Override
public void commit() throws PersistenceException {
try {
this.session.save();
@@ -302,37 +328,43 @@ public class MockedResourceResolver implements ResourceResolver {
}
}
+ @Override
public boolean hasChanges() {
throw new UnsupportedOperationException("Not implemented");
}
+ @Override
public String getParentResourceType(Resource resource) {
// TODO Auto-generated method stub
return null;
}
+ @Override
public String getParentResourceType(String resourceType) {
// TODO Auto-generated method stub
return null;
}
+ @Override
public boolean isResourceType(Resource resource, String resourceType) {
// TODO Auto-generated method stub
return false;
}
+ @Override
public void refresh() {
// TODO Auto-generated method stub
}
@Override
- public Resource getParent(Resource child) {
- throw new UnsupportedOperationException("Not implemented");
+ public boolean hasChildren(Resource arg0) {
+ Iterable<Resource> iter = this.getChildren(arg0);
+ return iter.iterator().hasNext();
}
@Override
- public boolean hasChildren(Resource resource) {
+ public Resource getParent(Resource child) {
throw new UnsupportedOperationException("Not implemented");
}
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/RepositoryTestHelper.java b/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/RepositoryTestHelper.java
index 1d2ff35..4421868 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/RepositoryTestHelper.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/RepositoryTestHelper.java
@@ -64,10 +64,10 @@ import org.slf4j.LoggerFactory;
public class RepositoryTestHelper {
private final static Logger logger = LoggerFactory.getLogger(RepositoryTestHelper.class);
-
+
public static void dumpRepo(ResourceResolverFactory resourceResolverFactory) throws Exception {
Session session = resourceResolverFactory
- .getAdministrativeResourceResolver(null).adaptTo(Session.class);
+ .getServiceResourceResolver(null).adaptTo(Session.class);
logger.info("dumpRepo: ====== START =====");
logger.info("dumpRepo: repo = " + session.getRepository());
@@ -78,7 +78,7 @@ public class RepositoryTestHelper {
session.logout();
}
-
+
public static void dump(Node node) throws RepositoryException {
if (node.getPath().equals("/jcr:system")
|| node.getPath().equals("/rep:policy")) {
@@ -153,7 +153,7 @@ public class RepositoryTestHelper {
public static Repository createOakRepository() {
return createOakRepository(new MemoryNodeStore());
}
-
+
public static Repository createOakRepository(NodeStore nodeStore) {
DefaultWhiteboard whiteboard = new DefaultWhiteboard();
final Oak oak = new Oak(nodeStore)
@@ -191,7 +191,7 @@ public class RepositoryTestHelper {
// .withAsyncIndexing()
.with(whiteboard)
;
-
+
// if (commitRateLimiter != null) {
// oak.with(commitRateLimiter);
// }
@@ -229,14 +229,16 @@ public class RepositoryTestHelper {
context.checking(new Expectations() {
{
allowing(resourceResolverFactory)
- .getAdministrativeResourceResolver(null);
+ .getServiceResourceResolver(null);
will(new Action() {
+ @Override
public Object invoke(Invocation invocation)
throws Throwable {
return new MockedResourceResolver(repositoryOrNull);
}
+ @Override
public void describeTo(Description arg0) {
arg0.appendText("whateva - im going to create a new mockedresourceresolver");
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-discovery-commons] 01/04:
[maven-release-plugin] prepare for next development iteration
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.discovery.commons-1.0.18
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git
commit 5e52b0c2ce2bc19602c3dd8d6f0b2130734b9d53
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Sep 26 09:49:56 2016 +0000
[maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons@1762304 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 71e222f..bf7db40 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,15 +29,15 @@
<artifactId>org.apache.sling.discovery.commons</artifactId>
<packaging>bundle</packaging>
- <version>1.0.16</version>
+ <version>1.0.17-SNAPSHOT</version>
<name>Apache Sling Discovery Commons</name>
<description>Common services related to Sling Discovery</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.commons-1.0.16</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.commons-1.0.16</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.discovery.commons-1.0.16</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/commons</url>
</scm>
<properties>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-discovery-commons] 04/04:
[maven-release-plugin] copy for tag
org.apache.sling.discovery.commons-1.0.18
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.discovery.commons-1.0.18
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git
commit b0387f58804882faa6ef5247a4b3366c566ca3d2
Author: Stefan Egli <st...@apache.org>
AuthorDate: Tue Nov 15 12:44:54 2016 +0000
[maven-release-plugin] copy for tag org.apache.sling.discovery.commons-1.0.18
git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.commons-1.0.18@1769806 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.