You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/09/22 17:15:47 UTC
[01/25] usergrid git commit: remove batch consumer
Repository: usergrid
Updated Branches:
refs/heads/usergrid-1007-shiro-cache 39f49d869 -> dc7681f47
remove batch consumer
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/9d22a91d
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/9d22a91d
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/9d22a91d
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 9d22a91dbca4ea854f253595b218ebcf1a2f0e1d
Parents: 723ee3a
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 13:11:12 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 13:11:12 2015 -0600
----------------------------------------------------------------------
.../usergrid/persistence/index/IndexFig.java | 14 ----
.../index/impl/EsIndexBufferConsumerImpl.java | 87 +++++++++-----------
.../index/impl/IndexBufferConsumer.java | 2 +
.../index/impl/IndexRefreshCommandImpl.java | 1 +
4 files changed, 44 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/9d22a91d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
index 5997029..db1ef3d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
@@ -153,21 +153,7 @@ public interface IndexFig extends GuicyFig {
@Default( "2" )
int getIndexCacheMaxWorkers();
- /**
- * The maximum time to wait before the buffer flushes and sends index write requests to Elasticsearch.
- * This is used so the application doesn't wait forever for the buffer to reach its size before writing
- * data to Elasticsearch.
- */
- @Default( "250" )
- @Key( INDEX_BUFFER_TIMEOUT )
- long getIndexBufferTimeout();
- /**
- * The maximum buffer size to use before sending index write requests to Elasticsearch.
- */
- @Default( "1000" )
- @Key( INDEX_BUFFER_SIZE )
- int getIndexBufferSize();
/**
* The number of worker threads used for flushing batches of index write requests
http://git-wip-us.apache.org/repos/asf/usergrid/blob/9d22a91d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
index 2c7122b..ca8cb82 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
@@ -102,12 +102,12 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
public Observable<IndexOperationMessage> put( IndexOperationMessage message ) {
Preconditions.checkNotNull(message, "Message cannot be null");
- indexSizeCounter.inc( message.getDeIndexRequests().size() );
- indexSizeCounter.inc( message.getIndexRequests().size() );
+ indexSizeCounter.inc(message.getDeIndexRequests().size());
+ indexSizeCounter.inc(message.getIndexRequests().size());
Timer.Context time = offerTimer.time();
- bufferProducer.send( message );
+ bufferProducer.send(message);
time.stop();
- return message.observable();
+ return message.observable();
}
@@ -116,22 +116,20 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
*/
private void startSubscription() {
-
+ //buffer on our new thread with a timeout
final Observable<IndexOperationMessage> observable = Observable.create(bufferProducer);
- //buffer on our new thread with a timeout
- observable.buffer( indexFig.getIndexBufferTimeout(), TimeUnit.MILLISECONDS, indexFig.getIndexBufferSize(),
- Schedulers.io() ).flatMap( indexOpBuffer -> {
+ observable.subscribeOn(Schedulers.io()).flatMap(indexOpBuffer -> {
//hand off to processor in new observable thread so we can continue to buffer faster
- return Observable.just( indexOpBuffer ).flatMap(
- indexOpBufferObservable -> ObservableTimer.time( processBatch( indexOpBufferObservable ),flushTimer )
+ return Observable.just(indexOpBuffer).flatMap(
+ indexOpBufferObservable -> ObservableTimer.time(processBatch(indexOpBufferObservable), flushTimer)
)
//use the I/O scheduler for thread re-use and efficiency in context switching then use our concurrent
// flatmap count or higher throughput of batches once buffered
- .subscribeOn( Schedulers.io() );
- }, indexFig.getIndexFlushWorkerCount() )
+ .subscribeOn(Schedulers.io());
+ }, indexFig.getIndexFlushWorkerCount())
//start in the background
.subscribe();
}
@@ -139,63 +137,60 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
/**
* Process the buffer of batches
- * @param batches
+ * @param batch
* @return
*/
- private Observable<IndexOperationMessage> processBatch( final List<IndexOperationMessage> batches ) {
+ private Observable<IndexOperationMessage> processBatch( final IndexOperationMessage batch ) {
- final Observable<IndexOperationMessage> indexOps = Observable.from( batches );
-
//take our stream of batches, then stream then into individual ops for consumption on ES
- final Observable<BatchOperation> batchOps = indexOps.flatMap( batch -> {
- final Set<IndexOperation> indexOperationSet = batch.getIndexRequests();
- final Set<DeIndexOperation> deIndexOperationSet = batch.getDeIndexRequests();
- final int indexOperationSetSize = indexOperationSet.size();
- final int deIndexOperationSetSize = deIndexOperationSet.size();
+ final Set<IndexOperation> indexOperationSet = batch.getIndexRequests();
+ final Set<DeIndexOperation> deIndexOperationSet = batch.getDeIndexRequests();
+
+ final int indexOperationSetSize = indexOperationSet.size();
+ final int deIndexOperationSetSize = deIndexOperationSet.size();
- log.debug( "Emitting {} add and {} remove operations", indexOperationSetSize, deIndexOperationSetSize );
+ log.debug("Emitting {} add and {} remove operations", indexOperationSetSize, deIndexOperationSetSize);
- indexSizeCounter.dec( indexOperationSetSize );
- indexSizeCounter.dec( deIndexOperationSetSize );
+ indexSizeCounter.dec(indexOperationSetSize);
+ indexSizeCounter.dec(deIndexOperationSetSize);
- final Observable<IndexOperation> index = Observable.from( batch.getIndexRequests() );
- final Observable<DeIndexOperation> deIndex = Observable.from( batch.getDeIndexRequests() );
+ final Observable<IndexOperation> index = Observable.from(batch.getIndexRequests());
+ final Observable<DeIndexOperation> deIndex = Observable.from(batch.getDeIndexRequests());
- return Observable.merge( index, deIndex );
- } );
+ final Observable<BatchOperation> batchOps = Observable.merge(index, deIndex);
//buffer into the max size we can send ES and fire them all off until we're completed
- final Observable<BulkRequestBuilder> requests = batchOps.buffer( indexFig.getIndexBatchSize() )
+ final Observable<BulkRequestBuilder> requests = batchOps.buffer(indexFig.getIndexBatchSize())
//flatten the buffer into a single batch execution
- .flatMap( individualOps -> Observable.from( individualOps )
+ .flatMap(individualOps -> Observable.from(individualOps)
//collect them
- .collect( () -> initRequest(), ( bulkRequestBuilder, batchOperation ) -> {
- log.debug( "adding operation {} to bulkRequestBuilder {}", batchOperation, bulkRequestBuilder );
- batchOperation.doOperation( client, bulkRequestBuilder );
- } ) )
+ .collect(() -> initRequest(), (bulkRequestBuilder, batchOperation) -> {
+ log.debug("adding operation {} to bulkRequestBuilder {}", batchOperation, bulkRequestBuilder);
+ batchOperation.doOperation(client, bulkRequestBuilder);
+ }))
//write them
- .doOnNext( bulkRequestBuilder -> sendRequest( bulkRequestBuilder ) );
+ .doOnNext(bulkRequestBuilder -> sendRequest(bulkRequestBuilder));
//now that we've processed them all, ack the futures after our last batch comes through
final Observable<IndexOperationMessage> processedIndexOperations =
- requests.lastOrDefault(null).flatMap( lastRequest ->{
- if(lastRequest!=null){
- return Observable.from( batches ) ;
- }else{
+ requests.lastOrDefault(null).flatMap(lastRequest -> {
+ if (lastRequest != null) {
+ return Observable.just(batch);
+ } else {
return Observable.empty();
}
});
//subscribe to the operations that generate requests on a new thread so that we can execute them quickly
//mark this as done
- return processedIndexOperations.doOnNext( processedIndexOp -> {
- processedIndexOp.done();
- roundtripTimer.update( System.currentTimeMillis() - processedIndexOp.getCreationTime() );
- } );
+ return processedIndexOperations.doOnNext(processedIndexOp -> {
+ processedIndexOp.done();
+ roundtripTimer.update(System.currentTimeMillis() - processedIndexOp.getCreationTime());
+ });
}
@@ -268,12 +263,12 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
/**
* Send the data through the buffer
*/
- public void send( final IndexOperationMessage indexOp ) {
+ public void send( final IndexOperationMessage indexOps ) {
try {
- subscriber.onNext( indexOp );
+ subscriber.onNext( indexOps );
}catch(Exception e){
//re-throws so the caller can determine failover
- log.error( "Unable to process message for indexOp {}, error follows.", indexOp, e );
+ log.error( "Unable to process message for indexOp {}, error follows.", indexOps, e );
throw e;
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/9d22a91d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
index 2906570..20b60b7 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
@@ -22,6 +22,8 @@ package org.apache.usergrid.persistence.index.impl;
import rx.Observable;
+import java.util.List;
+
/**
* Buffer index requests
http://git-wip-us.apache.org/repos/asf/usergrid/blob/9d22a91d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
index 9a2f2dc..0b749a9 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
@@ -20,6 +20,7 @@
package org.apache.usergrid.persistence.index.impl;
+import java.util.Collections;
import java.util.Map;
import java.util.UUID;
[23/25] usergrid git commit: restoring correct project version number
of 2.1.0-SNAPSHOT
Posted by sn...@apache.org.
restoring correct project version number of 2.1.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/a527d0d0
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/a527d0d0
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/a527d0d0
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: a527d0d0ec7f073722f10e6bbdf9f4e91b28f3ca
Parents: 684bf2a
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Sep 21 16:39:43 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Sep 21 16:39:43 2015 -0400
----------------------------------------------------------------------
stack/build-tools/pom.xml | 2 +-
stack/config/pom.xml | 2 +-
stack/core/pom.xml | 14 +++++++-------
stack/corepersistence/collection/pom.xml | 2 +-
stack/corepersistence/common/pom.xml | 2 +-
stack/corepersistence/graph/pom.xml | 2 +-
stack/corepersistence/map/pom.xml | 2 +-
stack/corepersistence/model/pom.xml | 2 +-
stack/corepersistence/pom.xml | 2 +-
stack/corepersistence/queryindex/pom.xml | 2 +-
stack/corepersistence/queue/pom.xml | 2 +-
stack/pom.xml | 2 +-
stack/rest/pom.xml | 2 +-
stack/services/pom.xml | 2 +-
stack/test-utils/pom.xml | 2 +-
15 files changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/build-tools/pom.xml
----------------------------------------------------------------------
diff --git a/stack/build-tools/pom.xml b/stack/build-tools/pom.xml
index 27c558a..eb84fea 100644
--- a/stack/build-tools/pom.xml
+++ b/stack/build-tools/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/config/pom.xml
----------------------------------------------------------------------
diff --git a/stack/config/pom.xml b/stack/config/pom.xml
index bc8f87a..32de5aa 100644
--- a/stack/config/pom.xml
+++ b/stack/config/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index a6eb5e8..be2d28c 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
@@ -418,7 +418,7 @@
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>common</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
@@ -427,7 +427,7 @@
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>collection</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<type>jar</type>
<exclusions>
<exclusion>
@@ -445,28 +445,28 @@
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>queryindex</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>graph</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>map</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>queue</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/corepersistence/collection/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/pom.xml b/stack/corepersistence/collection/pom.xml
index ccb5fc5..4eaa393 100644
--- a/stack/corepersistence/collection/pom.xml
+++ b/stack/corepersistence/collection/pom.xml
@@ -6,7 +6,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/corepersistence/common/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/pom.xml b/stack/corepersistence/common/pom.xml
index d7ac1ee..84f09de 100644
--- a/stack/corepersistence/common/pom.xml
+++ b/stack/corepersistence/common/pom.xml
@@ -5,7 +5,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/corepersistence/graph/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/pom.xml b/stack/corepersistence/graph/pom.xml
index 460bdca..3dde8bb 100644
--- a/stack/corepersistence/graph/pom.xml
+++ b/stack/corepersistence/graph/pom.xml
@@ -24,7 +24,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/corepersistence/map/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/pom.xml b/stack/corepersistence/map/pom.xml
index c84db70..7b367ba 100644
--- a/stack/corepersistence/map/pom.xml
+++ b/stack/corepersistence/map/pom.xml
@@ -22,7 +22,7 @@ limitations under the License.
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/corepersistence/model/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/pom.xml b/stack/corepersistence/model/pom.xml
index aac3d87..591935f 100644
--- a/stack/corepersistence/model/pom.xml
+++ b/stack/corepersistence/model/pom.xml
@@ -5,7 +5,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index 8fb1d25..4b47bc0 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -26,7 +26,7 @@ limitations under the License.
<artifactId>persistence</artifactId>
<name>Usergrid Persistence</name>
<packaging>pom</packaging>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<profiles>
<!-- better to have keep this sonar profile in your maven settings.xml -->
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/corepersistence/queryindex/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/pom.xml b/stack/corepersistence/queryindex/pom.xml
index 97732ff..2484cfd 100644
--- a/stack/corepersistence/queryindex/pom.xml
+++ b/stack/corepersistence/queryindex/pom.xml
@@ -6,7 +6,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/corepersistence/queue/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/pom.xml b/stack/corepersistence/queue/pom.xml
index 86d387d..2d46dc8 100644
--- a/stack/corepersistence/queue/pom.xml
+++ b/stack/corepersistence/queue/pom.xml
@@ -24,7 +24,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index c05eae7..93733aa 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -27,7 +27,7 @@
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<name>Usergrid Parent</name>
<description>Parent module for the Apache Usergrid Project</description>
<packaging>pom</packaging>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 2aee114..ebbc375 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-rest</artifactId>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index 82f7373..a771b34 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/a527d0d0/stack/test-utils/pom.xml
----------------------------------------------------------------------
diff --git a/stack/test-utils/pom.xml b/stack/test-utils/pom.xml
index bb80546..b28d170 100644
--- a/stack/test-utils/pom.xml
+++ b/stack/test-utils/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>2.1.0-JERSEY-TEST</version>
+ <version>2.1.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-test-utils</artifactId>
[22/25] usergrid git commit: Merge branch 'two-dot-o-dev' into
usergrid-1007-shiro-cache
Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-1007-shiro-cache
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/ee66318c
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/ee66318c
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/ee66318c
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: ee66318c5394f9d17f707bc10bb7d5939e9dabe2
Parents: 39f49d8 684bf2a
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Sep 21 14:38:02 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Sep 21 14:38:02 2015 -0400
----------------------------------------------------------------------
.../usergrid/corepersistence/CoreModule.java | 4 -
.../corepersistence/CpEntityManager.java | 31 +-
.../corepersistence/CpRelationManager.java | 27 +-
.../asyncevents/EventBuilderImpl.java | 44 +--
.../corepersistence/index/IndexServiceImpl.java | 26 +-
.../read/search/CandidateEntityFilter.java | 15 +-
.../pipeline/read/search/CandidateIdFilter.java | 14 +-
.../usergrid/persistence/EntityManager.java | 2 +
.../corepersistence/StaleIndexCleanupTest.java | 14 +-
.../usergrid/persistence/CollectionIT.java | 10 +-
.../usergrid/persistence/PermissionsIT.java | 7 +-
.../core/future/FutureObservable.java | 44 ---
.../persistence/index/EntityIndexBatch.java | 8 +-
.../usergrid/persistence/index/IndexFig.java | 18 --
.../persistence/index/guice/IndexModule.java | 2 +-
.../index/impl/EsEntityIndexBatchImpl.java | 21 +-
.../index/impl/EsEntityIndexFactoryImpl.java | 8 +-
.../index/impl/EsEntityIndexImpl.java | 6 +-
.../index/impl/EsIndexBufferConsumerImpl.java | 286 -------------------
.../index/impl/EsIndexProducerImpl.java | 218 ++++++++++++++
.../index/impl/IndexBufferConsumer.java | 36 ---
.../index/impl/IndexOperationMessage.java | 18 --
.../persistence/index/impl/IndexProducer.java | 39 +++
.../index/impl/IndexRefreshCommandImpl.java | 4 +-
.../persistence/index/impl/EntityIndexTest.java | 66 ++---
.../persistence/index/impl/GeoPagingTest.java | 5 +-
.../index/impl/IndexLoadTestsIT.java | 6 +-
.../usergrid/rest/ApplicationsResource.java | 166 -----------
.../apache/usergrid/rest/DatabaseResource.java | 99 -------
.../apache/usergrid/rest/SystemResource.java | 19 +-
.../rest/system/ApplicationsResource.java | 168 +++++++++++
.../usergrid/rest/system/DatabaseResource.java | 101 +++++++
.../rest/system/QueueSystemResource.java | 77 +++++
.../apache/usergrid/rest/SystemResourceIT.java | 24 +-
.../collection/groups/GroupResourceIT.java | 6 +-
.../test/resource/endpoints/NamedResource.java | 163 ++++++-----
.../test/resource/endpoints/RootResource.java | 5 +
.../test/resource/endpoints/SubResource.java | 37 +++
.../test/resource/endpoints/SystemResource.java | 7 +-
.../test/resource/endpoints/UrlResource.java | 8 +
.../services/notifications/gcm/GCMAdapter.java | 7 +-
.../usergrid/services/roles/RolesService.java | 12 -
42 files changed, 956 insertions(+), 922 deletions(-)
----------------------------------------------------------------------
[08/25] usergrid git commit: remove batch.execute
Posted by sn...@apache.org.
remove batch.execute
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/c03a7298
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c03a7298
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c03a7298
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: c03a729817dd7bf5e336a6fe4c9be5984e4b3fb5
Parents: c05d973
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 08:21:59 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 08:21:59 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 6 +-
.../corepersistence/CpEntityManagerFactory.java | 5 +-
.../corepersistence/CpRelationManager.java | 16 ++---
.../corepersistence/index/IndexServiceImpl.java | 22 ++++---
.../read/search/CandidateEntityFilter.java | 14 +++--
.../pipeline/read/search/CandidateIdFilter.java | 14 +++--
.../persistence/index/EntityIndexBatch.java | 7 ++-
.../index/impl/EsEntityIndexBatchImpl.java | 14 ++---
.../index/impl/EsIndexProducerImpl.java | 9 ++-
.../persistence/index/impl/IndexProducer.java | 2 +
.../persistence/index/impl/EntityIndexTest.java | 66 ++++++++++----------
.../persistence/index/impl/GeoPagingTest.java | 5 +-
.../index/impl/IndexLoadTestsIT.java | 6 +-
13 files changed, 115 insertions(+), 71 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index d46c112..e222f68 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -41,6 +41,7 @@ import org.apache.usergrid.corepersistence.service.ConnectionService;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.IndexLocationStrategy;
import org.apache.usergrid.persistence.index.IndexRefreshCommand;
+import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
@@ -183,6 +184,7 @@ public class CpEntityManager implements EntityManager {
private final UUID applicationId;
private final EntityManagerFig entityManagerFig;
+ private final IndexProducer indexProducer;
private Application application;
@@ -246,9 +248,11 @@ public class CpEntityManager implements EntityManager {
final GraphManagerFactory graphManagerFactory,
final CollectionService collectionService,
final ConnectionService connectionService,
+ final IndexProducer indexProducer,
final UUID applicationId ) {
this.entityManagerFig = entityManagerFig;
+ this.indexProducer = indexProducer;
Preconditions.checkNotNull( cass, "cass must not be null" );
Preconditions.checkNotNull( counterUtils, "counterUtils must not be null" );
@@ -759,7 +763,7 @@ public class CpEntityManager implements EntityManager {
Preconditions.checkNotNull(entityRef, "entityRef cannot be null");
CpRelationManager relationManager =
- new CpRelationManager( managerCache, indexService, collectionService, connectionService, this, entityManagerFig, applicationId, entityRef );
+ new CpRelationManager(managerCache, indexService, collectionService, connectionService, indexProducer, this, entityManagerFig, applicationId, entityRef );
return relationManager;
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 4bdade5..4a712a7 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -22,6 +22,7 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
+import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
@@ -96,6 +97,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
private static final Logger logger = LoggerFactory.getLogger( CpEntityManagerFactory.class );
private final EntityManagerFig entityManagerFig;
+ private final IndexProducer indexProducer;
private ApplicationContext applicationContext;
@@ -137,6 +139,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
this.graphManagerFactory = injector.getInstance( GraphManagerFactory.class );
this.collectionService = injector.getInstance( CollectionService.class );
this.connectionService = injector.getInstance( ConnectionService.class );
+ this.indexProducer = injector.getInstance(IndexProducer.class);
//this line always needs to be last due to the temporary cicular dependency until spring is removed
this.applicationIdCache = injector.getInstance(ApplicationIdCacheFactory.class).getInstance(
@@ -199,7 +202,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
private EntityManager _getEntityManager( UUID applicationId ) {
EntityManager em = new CpEntityManager(cassandraService, counterUtils, indexService, managerCache,
- metricsFactory, entityManagerFig, graphManagerFactory, collectionService, connectionService, applicationId );
+ metricsFactory, entityManagerFig, graphManagerFactory, collectionService, connectionService, indexProducer, applicationId );
return em;
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 0c3b927..c393fb2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
@@ -105,6 +106,7 @@ public class CpRelationManager implements RelationManager {
private static final Logger logger = LoggerFactory.getLogger( CpRelationManager.class );
private final EntityManagerFig entityManagerFig;
+ private final IndexProducer indexProducer;
private ManagerCache managerCache;
@@ -127,9 +129,11 @@ public class CpRelationManager implements RelationManager {
public CpRelationManager( final ManagerCache managerCache,
final AsyncEventService indexService, final CollectionService collectionService,
- final ConnectionService connectionService, final EntityManager em,
+ final ConnectionService connectionService,final IndexProducer indexProducer,
+ final EntityManager em,
final EntityManagerFig entityManagerFig, final UUID applicationId,
- final EntityRef headEntity ) {
+ final EntityRef headEntity) {
+ this.indexProducer = indexProducer;
Assert.notNull( em, "Entity manager cannot be null" );
@@ -529,16 +533,14 @@ public class CpRelationManager implements RelationManager {
*/
final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
- final EntityIndexBatch batch = ei.createBatch();
// remove item from collection index
SearchEdge indexScope = createCollectionSearchEdge( cpHeadEntity.getId(), collectionName );
+ final EntityIndexBatch batch = ei.createBatch();
batch.deindex( indexScope, memberEntity );
-
-
- batch.execute();
-
+ //TODO: this should not happen here, needs to go to SQS
+ indexProducer.put(batch).subscribe();
// special handling for roles collection of a group
if ( headEntity.getType().equals( Group.ENTITY_TYPE ) ) {
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
index 8a8dba1..be7dc20 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
@@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.UUID;
import org.apache.usergrid.persistence.index.*;
+import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.apache.usergrid.utils.UUIDUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,18 +69,25 @@ public class IndexServiceImpl implements IndexService {
private final EdgesObservable edgesObservable;
private final IndexFig indexFig;
private final IndexLocationStrategyFactory indexLocationStrategyFactory;
+ private final IndexProducer indexProducer;
private final Timer indexTimer;
private final Timer addTimer;
@Inject
- public IndexServiceImpl( final GraphManagerFactory graphManagerFactory, final EntityIndexFactory entityIndexFactory,
- final EdgesObservable edgesObservable, final IndexFig indexFig, final IndexLocationStrategyFactory indexLocationStrategyFactory, final MetricsFactory metricsFactory ) {
+ public IndexServiceImpl( final GraphManagerFactory graphManagerFactory,
+ final EntityIndexFactory entityIndexFactory,
+ final EdgesObservable edgesObservable,
+ final IndexFig indexFig,
+ final IndexLocationStrategyFactory indexLocationStrategyFactory,
+ final MetricsFactory metricsFactory,
+ final IndexProducer indexProducer) {
this.graphManagerFactory = graphManagerFactory;
this.entityIndexFactory = entityIndexFactory;
this.edgesObservable = edgesObservable;
this.indexFig = indexFig;
this.indexLocationStrategyFactory = indexLocationStrategyFactory;
+ this.indexProducer = indexProducer;
this.indexTimer = metricsFactory.getTimer( IndexServiceImpl.class, "index.update_all");
this.addTimer = metricsFactory.getTimer( IndexServiceImpl.class, "index.add" );
}
@@ -89,7 +97,7 @@ public class IndexServiceImpl implements IndexService {
public Observable<IndexOperationMessage> indexEntity( final ApplicationScope applicationScope,
final Entity entity ) {
//bootstrap the lower modules from their caches
- final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
+ final GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope);
final EntityIndex ei = entityIndexFactory.createEntityIndex(indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope));
@@ -114,7 +122,7 @@ public class IndexServiceImpl implements IndexService {
batch.index( indexEdge, entity );
} )
//return the future from the batch execution
- .flatMap( batch -> batch.execute() ) );
+ .flatMap( batch -> indexProducer.put(batch) ) );
return ObservableTimer.time( batches, indexTimer );
}
@@ -142,7 +150,7 @@ public class IndexServiceImpl implements IndexService {
batch.index( indexEdge, entity );
- return batch.execute();
+ return indexProducer.put(batch);
} );
return ObservableTimer.time( batches, addTimer );
@@ -185,7 +193,7 @@ public class IndexServiceImpl implements IndexService {
batch = deindexBatchIteratorResolver( fromTarget, sourceEdgesToBeDeindexed, batch );
- return batch.execute();
+ return indexProducer.put(batch);
} );
return ObservableTimer.time( batches, addTimer );
@@ -221,7 +229,7 @@ public class IndexServiceImpl implements IndexService {
batch.deindex( searchEdge, candidateResult );
} )
//return the future from the batch execution
- .flatMap( batch -> batch.execute() );
+ .flatMap( batch -> indexProducer.put(batch) );
return ObservableTimer.time(batches, indexTimer);
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
index 14c880f..ac2962a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
@@ -24,6 +24,7 @@ import java.util.*;
import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
import org.apache.usergrid.persistence.index.*;
+import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.apache.usergrid.persistence.model.field.Field;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,16 +57,19 @@ public class CandidateEntityFilter extends AbstractFilter<FilterResult<Candidate
private final EntityCollectionManagerFactory entityCollectionManagerFactory;
private final EntityIndexFactory entityIndexFactory;
private final IndexLocationStrategyFactory indexLocationStrategyFactory;
+ private final IndexProducer producer;
@Inject
public CandidateEntityFilter( final EntityCollectionManagerFactory entityCollectionManagerFactory,
final EntityIndexFactory entityIndexFactory,
- final IndexLocationStrategyFactory indexLocationStrategyFactory
+ final IndexLocationStrategyFactory indexLocationStrategyFactory,
+ final IndexProducer producer
) {
this.entityCollectionManagerFactory = entityCollectionManagerFactory;
this.entityIndexFactory = entityIndexFactory;
this.indexLocationStrategyFactory = indexLocationStrategyFactory;
+ this.producer = producer;
}
@@ -107,7 +111,7 @@ public class CandidateEntityFilter extends AbstractFilter<FilterResult<Candidate
.flatMap(idList -> entityCollectionManager.load(idList));
//now we have a collection, validate our canidate set is correct.
return entitySets.map(
- entitySet -> new EntityVerifier(
+ entitySet -> new EntityVerifier(producer,
applicationIndex.createBatch(), entitySet, candidateResults)
)
.doOnNext(entityCollector -> entityCollector.merge())
@@ -148,13 +152,15 @@ public class CandidateEntityFilter extends AbstractFilter<FilterResult<Candidate
private static final Logger logger = LoggerFactory.getLogger( EntityVerifier.class );
private List<FilterResult<Entity>> results = new ArrayList<>();
+ private final IndexProducer producer;
private final EntityIndexBatch batch;
private final List<FilterResult<Candidate>> candidateResults;
private final EntitySet entitySet;
- public EntityVerifier( final EntityIndexBatch batch, final EntitySet entitySet,
+ public EntityVerifier( final IndexProducer producer, final EntityIndexBatch batch, final EntitySet entitySet,
final List<FilterResult<Candidate>> candidateResults ) {
+ this.producer = producer;
this.batch = batch;
this.entitySet = entitySet;
this.candidateResults = candidateResults;
@@ -171,7 +177,7 @@ public class CandidateEntityFilter extends AbstractFilter<FilterResult<Candidate
validate( candidateResult );
}
- batch.execute().subscribe();
+ producer.put(batch).subscribe();
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java
index 3b1c102..b00efee 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java
@@ -26,6 +26,7 @@ import java.util.UUID;
import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
import org.apache.usergrid.persistence.index.*;
+import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,15 +54,18 @@ public class CandidateIdFilter extends AbstractFilter<FilterResult<Candidate>, F
private final EntityCollectionManagerFactory entityCollectionManagerFactory;
private final EntityIndexFactory entityIndexFactory;
private final IndexLocationStrategyFactory indexLocationStrategyFactory;
+ private final IndexProducer indexProducer;
@Inject
public CandidateIdFilter( final EntityCollectionManagerFactory entityCollectionManagerFactory,
final EntityIndexFactory entityIndexFactory,
- final IndexLocationStrategyFactory indexLocationStrategyFactory) {
+ final IndexLocationStrategyFactory indexLocationStrategyFactory,
+ final IndexProducer indexProducer) {
this.entityCollectionManagerFactory = entityCollectionManagerFactory;
this.entityIndexFactory = entityIndexFactory;
this.indexLocationStrategyFactory = indexLocationStrategyFactory;
+ this.indexProducer = indexProducer;
}
@@ -96,7 +100,7 @@ public class CandidateIdFilter extends AbstractFilter<FilterResult<Candidate>, F
//now we have a collection, validate our canidate set is correct.
return versionSetObservable.map(
- entitySet -> new EntityCollector( applicationIndex.createBatch(), entitySet,
+ entitySet -> new EntityCollector(indexProducer, applicationIndex.createBatch(), entitySet,
candidateResults ) ).doOnNext( entityCollector -> entityCollector.merge() ).flatMap(
entityCollector -> Observable.from( entityCollector.collectResults() ) );
} );
@@ -113,13 +117,15 @@ public class CandidateIdFilter extends AbstractFilter<FilterResult<Candidate>, F
private static final Logger logger = LoggerFactory.getLogger( EntityCollector.class );
private List<FilterResult<Id>> results = new ArrayList<>();
+ private final IndexProducer indexProducer;
private final EntityIndexBatch batch;
private final List<FilterResult<Candidate>> candidateResults;
private final VersionSet versionSet;
- public EntityCollector( final EntityIndexBatch batch, final VersionSet versionSet,
+ public EntityCollector( final IndexProducer indexProducer, final EntityIndexBatch batch, final VersionSet versionSet,
final List<FilterResult<Candidate>> candidateResults ) {
+ this.indexProducer = indexProducer;
this.batch = batch;
this.versionSet = versionSet;
this.candidateResults = candidateResults;
@@ -136,7 +142,7 @@ public class CandidateIdFilter extends AbstractFilter<FilterResult<Candidate>, F
validate( candidateResult );
}
- batch.execute();
+ indexProducer.put(batch).subscribe();
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
index d1b076d..baca504 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
@@ -63,10 +63,11 @@ public interface EntityIndexBatch {
/**
- * Execute the batch
- * @return future to guarantee execution
+ * return built payload
+ * @return
*/
- Observable<IndexOperationMessage> execute();
+ IndexOperationMessage build();
+
/**
* Get the number of operations in the batch
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index 64a1c6a..3679887 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -66,8 +66,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
@Override
public EntityIndexBatch index( final IndexEdge indexEdge, final Entity entity ) {
- IndexValidationUtils.validateIndexEdge( indexEdge );
- ValidationUtils.verifyEntityWrite( entity );
+ IndexValidationUtils.validateIndexEdge(indexEdge);
+ ValidationUtils.verifyEntityWrite(entity);
ValidationUtils.verifyVersion( entity.getVersion() );
final String writeAlias = alias.getWriteAlias();
@@ -78,7 +78,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
}
//add app id for indexing
- container.addIndexRequest( new IndexOperation( writeAlias, applicationScope, indexEdge, entity ) );
+ container.addIndexRequest(new IndexOperation(writeAlias, applicationScope, indexEdge, entity));
return this;
}
@@ -115,18 +115,16 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
@Override
- public EntityIndexBatch deindex( final SearchEdge searchEdge, final CandidateResult entity ) {
+ public EntityIndexBatch deindex(final SearchEdge searchEdge, final CandidateResult entity) {
return deindex( searchEdge, entity.getId(), entity.getVersion() );
}
-
@Override
- public Observable execute() {
- return indexBatchBufferProducer.put( container );
+ public IndexOperationMessage build(){
+ return container;
}
-
@Override
public int size() {
return container.getDeIndexRequests().size() + container.getIndexRequests().size();
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
index efce823..ef59abb 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
@@ -24,6 +24,7 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import com.codahale.metrics.Histogram;
+import org.apache.usergrid.persistence.index.EntityIndexBatch;
import org.elasticsearch.action.WriteConsistencyLevel;
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
@@ -87,8 +88,14 @@ public class EsIndexProducerImpl implements IndexProducer {
}
+ public Observable<IndexOperationMessage> put( EntityIndexBatch batch ) {
+ Preconditions.checkNotNull(batch, "Batch cannot be null");
+ return put(batch.build());
+ }
+
public Observable<IndexOperationMessage> put( IndexOperationMessage message ) {
- Preconditions.checkNotNull(message, "Message cannot be null");
+
+ Preconditions.checkNotNull(message, "Message cannot be null");
indexSizeCounter.inc(message.getDeIndexRequests().size());
indexSizeCounter.inc(message.getIndexRequests().size());
return processBatch(message);
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
index e18ac50..8f3ab79 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
@@ -20,6 +20,7 @@
package org.apache.usergrid.persistence.index.impl;
+import org.apache.usergrid.persistence.index.EntityIndexBatch;
import rx.Observable;
@@ -34,6 +35,7 @@ public interface IndexProducer {
* @param message
* @return
*/
+ Observable<IndexOperationMessage> put(EntityIndexBatch message);
Observable<IndexOperationMessage> put(IndexOperationMessage message);
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 6348a44..2fd9d3b 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -77,6 +77,8 @@ public class EntityIndexTest extends BaseIT {
@Inject
public EntityIndexFactory eif;
+ @Inject
+ public IndexProducer indexProducer;
@Inject
public IndexFig fig;
@@ -133,25 +135,25 @@ public class EntityIndexTest extends BaseIT {
entity1.setField(new UUIDField(IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID()));
entity1.setField( new StringField( "testfield", "test" ) );
entity1.setField(new IntegerField("ordinal", 0));
- entity1.setField(new UUIDField("testuuid",uuid));
+ entity1.setField(new UUIDField("testuuid", uuid));
- batch.index( indexEdge, entity1 );
- batch.execute().toBlocking().last();
+ batch.index(indexEdge, entity1);
+ indexProducer.put(batch).subscribe();
Entity entity2 = new Entity( entityType );
- EntityUtils.setVersion( entity2, UUIDGenerator.newTimeUUID() );
+ EntityUtils.setVersion(entity2, UUIDGenerator.newTimeUUID());
List<String> list = new ArrayList<>();
- list.add( "test" );
- entity2.setField( new ArrayField<>( "testfield", list ) );
- entity2.setField( new IntegerField( "ordinal", 1 ) );
+ list.add("test");
+ entity2.setField(new ArrayField<>("testfield", list));
+ entity2.setField(new IntegerField("ordinal", 1));
- batch.index( indexEdge, entity2 );
- batch.execute().toBlocking().last();
+ batch.index(indexEdge, entity2);
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
@@ -163,14 +165,14 @@ public class EntityIndexTest extends BaseIT {
timer.stop();
- assertEquals( 2, candidateResults.size() );
- log.debug( "Query time {}ms", timer.getTime() );
+ assertEquals(2, candidateResults.size());
+ log.debug("Query time {}ms", timer.getTime());
final CandidateResult candidate1 = candidateResults.get(0);
//check the id and version
assertEquals( entity1.getId(), candidate1.getId() );
- assertEquals( entity1.getVersion(), candidate1.getVersion() );
+ assertEquals(entity1.getVersion(), candidate1.getVersion());
final CandidateResult candidate2 = candidateResults.get(1);
@@ -215,7 +217,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
insertJsonBlob( sampleJson, batch, entityType, indexEdge, size, 0 );
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
}
catch ( Exception e ) {
synchronized ( failTime ) {
@@ -290,7 +292,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch entityIndexBatch = entityIndex.createBatch();
entityIndexBatch.deindex(searchEdge, crs.get(0));
- entityIndexBatch.execute().toBlocking().last();
+ indexProducer.put(entityIndex.createBatch() ).subscribe();
entityIndex.refreshAsync().toBlocking().first();
//Hilda Youn
@@ -306,7 +308,7 @@ public class EntityIndexTest extends BaseIT {
});
EntityIndexBatch batch = entityIndex.createBatch();
insertJsonBlob(sampleJson, batch, entityType, indexEdge, max, startIndex);
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
IndexRefreshCommandImpl.IndexRefreshCommandInfo info = entityIndex.refreshAsync().toBlocking().first();
long time = info.getExecutionTime();
log.info("refresh took ms:" + time);
@@ -360,11 +362,11 @@ public class EntityIndexTest extends BaseIT {
Entity entity = EntityIndexMapUtils.fromMap( entityMap );
- EntityUtils.setId( entity, new SimpleId( "fastcar" ) );
- EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() );
- entity.setField( new UUIDField( IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID() ) );
+ EntityUtils.setId(entity, new SimpleId( "fastcar" ) );
+ EntityUtils.setVersion(entity, UUIDGenerator.newTimeUUID() );
+ entity.setField(new UUIDField(IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID() ) );
- entityIndex.createBatch().index( searchEdge, entity ).execute().toBlocking().last();
+ indexProducer.put(entityIndex.createBatch().index( searchEdge, entity )).toBlocking().last();
entityIndex.refreshAsync().toBlocking().first();
CandidateResults candidateResults = entityIndex
@@ -373,7 +375,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
batch.deindex( searchEdge, entity );
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
candidateResults = entityIndex
@@ -410,7 +412,7 @@ public class EntityIndexTest extends BaseIT {
entity[i].setField( new UUIDField( IndexingUtils.ENTITY_ID_FIELDNAME, entityUUID ) );
//index the new entity. This is where the loop will be set to create like 100 entities.
- entityIndex.createBatch().index( searchEdge, entity[i] ).execute().toBlocking().last();
+ indexProducer.put(entityIndex.createBatch().index( searchEdge, entity[i] )).toBlocking().last();
}
entityIndex.refreshAsync().toBlocking().first();
@@ -541,7 +543,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
batch.index( indexSCope, user );
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
final String query = "where username = 'edanuff'";
@@ -550,7 +552,7 @@ public class EntityIndexTest extends BaseIT {
assertEquals( user.getId(), r.get( 0 ).getId() );
batch.deindex( indexSCope, user.getId(), user.getVersion() );
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
// EntityRef
@@ -611,7 +613,7 @@ public class EntityIndexTest extends BaseIT {
EntityUtils.setVersion( fred, UUIDGenerator.newTimeUUID() );
batch.index( indexScope, fred);
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
final SearchTypes searchTypes = SearchTypes.fromTypes( "user" );
@@ -688,7 +690,7 @@ public class EntityIndexTest extends BaseIT {
}
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
@@ -755,7 +757,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
batch.index( indexSCope, user );
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
final String query = "where searchUUID = " + searchUUID;
@@ -794,7 +796,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
batch.index(indexSCope, user);
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
final String query = "where string = 'I am*'";
@@ -851,7 +853,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
batch.index( indexSCope, first );
batch.index( indexSCope, second );
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
@@ -916,7 +918,7 @@ public class EntityIndexTest extends BaseIT {
batch.index(indexScope2, second);
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
@@ -997,7 +999,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexScope2, second);
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
@@ -1107,7 +1109,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexScope2, second);
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
@@ -1262,7 +1264,7 @@ public class EntityIndexTest extends BaseIT {
batch.index( indexScope2, second);
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().first();
long size = entityIndex.getEntitySize(new SearchEdgeImpl(ownerId,type, SearchEdge.NodeType.SOURCE));
assertTrue( size == 100 );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
index fbe2bf5..7ecd7a1 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
@@ -82,6 +82,9 @@ public class GeoPagingTest extends BaseIT {
public CassandraFig cassandraFig;
@Inject
+ public IndexProducer indexProducer;
+
+ @Inject
@Rule
public ElasticSearchRule elasticSearchRule;
private EntityIndex entityIndex;
@@ -128,7 +131,7 @@ public class GeoPagingTest extends BaseIT {
}
- batch.execute().toBlocking().last();
+ indexProducer.put(batch).subscribe();
entityIndex.refreshAsync().toBlocking().last();
http://git-wip-us.apache.org/repos/asf/usergrid/blob/c03a7298/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
index cca3f0f..c34196e 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
@@ -87,6 +87,8 @@ public class IndexLoadTestsIT extends BaseIT {
@Rule
public MigrationManagerRule migrationManagerRule;
+ @Inject
+ public IndexProducer indexProducer;
@Inject
public IndexTestFig indexTestFig;
@@ -346,8 +348,8 @@ public class IndexLoadTestsIT extends BaseIT {
batchWriteTPS.mark();
- //execute
- entityIndexBatch.execute();
+ indexProducer.put(entityIndexBatch).subscribe();
+
//stop
time.close();
} ).toBlocking().last();
[17/25] usergrid git commit: add queue depth,
reorg rest into system folder
Posted by sn...@apache.org.
add queue depth, reorg rest into system folder
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/f04f50c1
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/f04f50c1
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/f04f50c1
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: f04f50c1b755dab02e11a82adb10820efb4c2078
Parents: 73dd687
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 18 12:08:37 2015 -0400
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 18 12:08:37 2015 -0400
----------------------------------------------------------------------
.../usergrid/rest/ApplicationsResource.java | 168 -------------------
.../apache/usergrid/rest/DatabaseResource.java | 98 -----------
.../apache/usergrid/rest/SystemResource.java | 14 +-
.../rest/system/ApplicationsResource.java | 168 +++++++++++++++++++
.../usergrid/rest/system/DatabaseResource.java | 100 +++++++++++
.../rest/system/QueueSystemResource.java | 78 +++++++++
.../apache/usergrid/rest/SystemResourceIT.java | 23 ++-
.../test/resource/endpoints/NamedResource.java | 34 +++-
.../test/resource/endpoints/RootResource.java | 5 +
.../test/resource/endpoints/SubResource.java | 37 ++++
.../test/resource/endpoints/UrlResource.java | 6 +
11 files changed, 449 insertions(+), 282 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
deleted file mode 100644
index 6127efc..0000000
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- *
- * * Licensed to the Apache Software Foundation (ASF) under one or more
- * * contributor license agreements. The ASF licenses this file to You
- * * under the Apache License, Version 2.0 (the "License"); you may not
- * * use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License. For additional information regarding
- * * copyright in this work, please see the NOTICE file in the top level
- * * directory of this distribution.
- *
- */
-package org.apache.usergrid.rest;
-
-import com.sun.jersey.api.json.JSONWithPadding;
-import org.apache.usergrid.corepersistence.service.StatusService;
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.core.util.StringUtils;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Classy class class.
- */
-@Component
-@Scope( "singleton" )
-@Produces( {
- MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
- "application/ecmascript", "text/jscript"
-} )
-public class ApplicationsResource extends AbstractContextResource {
-
- private static final Logger logger = LoggerFactory.getLogger(ApplicationsResource.class);
-
-
- public ApplicationsResource() {
-
- logger.info( "ApplicationsResource initialized" );
- } {
-
- }
-
- @RequireSystemAccess
- @DELETE
- @Path( "{applicationId}" )
- public JSONWithPadding clearApplication( @Context UriInfo ui,
- @PathParam("applicationId") UUID applicationId,
- @QueryParam( "confirmApplicationName" ) String confirmApplicationName,
- @QueryParam( "limit" ) int limit,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
- throws Exception {
-
- if(confirmApplicationName == null){
- throw new IllegalArgumentException("please make add a QueryString for confirmApplicationName");
- }
-
- final UUID jobId = UUIDGenerator.newTimeUUID();
-
- final EntityManager em = emf.getEntityManager(applicationId);
- final String name = em.getApplication().getApplicationName();
- if(!name.toLowerCase().equals(confirmApplicationName.toLowerCase())){
- throw new IllegalArgumentException("confirmApplicationName: " + confirmApplicationName + " does not equal " + name);
- }
- final StatusService statusService = injector.getInstance(StatusService.class);
-
- final ApiResponse response = createApiResponse();
-
- response.setAction( "clear application" );
-
- logger.info("clearing up application");
-
-
- final Thread delete = new Thread() {
-
- @Override
- public void run() {
- final AtomicInteger itemsDeleted = new AtomicInteger(0);
- try {
- management.deleteAllEntities(applicationId, limit)
- .map(id -> itemsDeleted.incrementAndGet())
- .doOnNext(count -> {
- if( count % 100 == 0 ){
- Map<String,Object> map = new LinkedHashMap<>();
- map.put("count",itemsDeleted.intValue());
- final StatusService statusService = injector.getInstance(StatusService.class);
- statusService.setStatus(applicationId, jobId, StatusService.Status.INPROGRESS,map).subscribe();
- }
- })
- .doOnCompleted(() ->{
- Map<String,Object> map = new LinkedHashMap<>();
- map.put("count",itemsDeleted.intValue());
- final StatusService statusService = injector.getInstance(StatusService.class);
- statusService.setStatus(applicationId,jobId, StatusService.Status.COMPLETE,map).subscribe();
- })
- .subscribe();
-
- } catch ( Exception e ) {
- Map<String,Object> map = new LinkedHashMap<>();
- map.put("exception",e);
- statusService.setStatus(applicationId,jobId, StatusService.Status.FAILED,map).subscribe();
- logger.error( "Failed to delete appid:"+applicationId + " jobid:"+jobId+" count:"+itemsDeleted, e );
- }
- }
- };
-
- delete.setName("Delete for app : " + applicationId + " job: " + jobId);
- delete.setDaemon(true);
- delete.start();
-
- statusService.setStatus(applicationId,jobId, StatusService.Status.STARTED,new LinkedHashMap<>()).subscribe();
-
- Map<String,Object> data = new HashMap<>();
- data.put("jobId",jobId);
- data.put("status",StatusService.Status.STARTED);
- response.setData(data);
- response.setSuccess();
- return new JSONWithPadding( response, callback );
- }
-
- @RequireSystemAccess
- @GET
- @Path( "{applicationId}/job/{jobId}" )
- public JSONWithPadding getStatus( @Context UriInfo ui,
- @PathParam("applicationId") UUID applicationId,
- @PathParam("jobId") UUID jobId,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception{
- final StatusService statusService = injector.getInstance(StatusService.class);
-
- final ApiResponse response = createApiResponse();
-
- response.setAction( "clear application" );
-
- StatusService.JobStatus jobStatus = statusService.getStatus(applicationId, jobId).toBlocking().lastOrDefault(null);
-
- Map<String,Object> data = new HashMap<>();
- data.put("jobId",jobId);
- data.put( "status", jobStatus.getStatus().toString() );
- data.put( "metadata", jobStatus.getData() );
- response.setData(data);
- response.setSuccess();
-
- return new JSONWithPadding( response, callback );
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/main/java/org/apache/usergrid/rest/DatabaseResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/DatabaseResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/DatabaseResource.java
deleted file mode 100644
index a8c5fee..0000000
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/DatabaseResource.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.rest;
-
-
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
-
-import com.sun.jersey.api.json.JSONWithPadding;
-
-
-@Component
-@Scope( "singleton" )
-@Produces( {
- MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
- "application/ecmascript", "text/jscript"
-} )
-public class DatabaseResource extends AbstractContextResource {
-
- private static final Logger logger = LoggerFactory.getLogger( DatabaseResource.class );
-
-
- public DatabaseResource() {
- logger.info( "DatabaseResource initialized" );
- }
-
-
- @RequireSystemAccess
- @PUT
- @Path( "setup" )
- public JSONWithPadding runDatabaseSetup( @Context UriInfo ui,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
- throws Exception {
-
- ApiResponse response = createApiResponse();
- response.setAction( "cassandra setup" );
-
- logger.info( "Setting up Cassandra" );
-
-
- emf.setup();
-
-
- response.setSuccess();
-
- return new JSONWithPadding( response, callback );
- }
-
-
- @RequireSystemAccess
- @PUT
- @Path( "bootstrap" )
- public JSONWithPadding runSystemSetup( @Context UriInfo ui,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
- throws Exception {
-
- ApiResponse response = createApiResponse();
- response.setAction( "cassandra setup" );
-
- logger.info( "Setting up Cassandra" );
-
-
- emf.boostrap();
- management.setup();
-
- response.setSuccess();
-
- return new JSONWithPadding( response, callback );
- }
-}
-
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
index f266441..fd85d94 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
@@ -22,6 +22,9 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
+import org.apache.usergrid.rest.system.ApplicationsResource;
+import org.apache.usergrid.rest.system.DatabaseResource;
+import org.apache.usergrid.rest.system.QueueSystemResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
@@ -31,12 +34,6 @@ import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
import com.sun.jersey.api.json.JSONWithPadding;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-
@Path( "/system" )
@Component
@@ -96,6 +93,11 @@ public class SystemResource extends AbstractContextResource {
return getSubResource( DatabaseResource.class );
}
+ @Path( "queue" )
+ public QueueSystemResource queue() {
+ return getSubResource( QueueSystemResource.class );
+ }
+
@Path( "applications" )
public ApplicationsResource applications() {
return getSubResource( ApplicationsResource.class );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/main/java/org/apache/usergrid/rest/system/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/system/ApplicationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/system/ApplicationsResource.java
new file mode 100644
index 0000000..724a8cf
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/system/ApplicationsResource.java
@@ -0,0 +1,168 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.rest.system;
+
+import com.sun.jersey.api.json.JSONWithPadding;
+import org.apache.usergrid.corepersistence.service.StatusService;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Classy class class.
+ */
+@Component
+@Scope( "singleton" )
+@Produces( {
+ MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+ "application/ecmascript", "text/jscript"
+} )
+public class ApplicationsResource extends AbstractContextResource {
+
+ private static final Logger logger = LoggerFactory.getLogger(ApplicationsResource.class);
+
+
+ public ApplicationsResource() {
+
+ logger.info( "ApplicationsResource initialized" );
+ } {
+
+ }
+
+ @RequireSystemAccess
+ @DELETE
+ @Path( "{applicationId}" )
+ public JSONWithPadding clearApplication( @Context UriInfo ui,
+ @PathParam("applicationId") UUID applicationId,
+ @QueryParam( "confirmApplicationName" ) String confirmApplicationName,
+ @QueryParam( "limit" ) int limit,
+ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+ throws Exception {
+
+ if(confirmApplicationName == null){
+ throw new IllegalArgumentException("please make add a QueryString for confirmApplicationName");
+ }
+
+ final UUID jobId = UUIDGenerator.newTimeUUID();
+
+ final EntityManager em = emf.getEntityManager(applicationId);
+ final String name = em.getApplication().getApplicationName();
+ if(!name.toLowerCase().equals(confirmApplicationName.toLowerCase())){
+ throw new IllegalArgumentException("confirmApplicationName: " + confirmApplicationName + " does not equal " + name);
+ }
+ final StatusService statusService = injector.getInstance(StatusService.class);
+
+ final ApiResponse response = createApiResponse();
+
+ response.setAction( "clear application" );
+
+ logger.info("clearing up application");
+
+
+ final Thread delete = new Thread() {
+
+ @Override
+ public void run() {
+ final AtomicInteger itemsDeleted = new AtomicInteger(0);
+ try {
+ management.deleteAllEntities(applicationId, limit)
+ .map(id -> itemsDeleted.incrementAndGet())
+ .doOnNext(count -> {
+ if( count % 100 == 0 ){
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("count",itemsDeleted.intValue());
+ final StatusService statusService = injector.getInstance(StatusService.class);
+ statusService.setStatus(applicationId, jobId, StatusService.Status.INPROGRESS,map).subscribe();
+ }
+ })
+ .doOnCompleted(() ->{
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("count",itemsDeleted.intValue());
+ final StatusService statusService = injector.getInstance(StatusService.class);
+ statusService.setStatus(applicationId,jobId, StatusService.Status.COMPLETE,map).subscribe();
+ })
+ .subscribe();
+
+ } catch ( Exception e ) {
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("exception",e);
+ statusService.setStatus(applicationId,jobId, StatusService.Status.FAILED,map).subscribe();
+ logger.error( "Failed to delete appid:"+applicationId + " jobid:"+jobId+" count:"+itemsDeleted, e );
+ }
+ }
+ };
+
+ delete.setName("Delete for app : " + applicationId + " job: " + jobId);
+ delete.setDaemon(true);
+ delete.start();
+
+ statusService.setStatus(applicationId,jobId, StatusService.Status.STARTED,new LinkedHashMap<>()).subscribe();
+
+ Map<String,Object> data = new HashMap<>();
+ data.put("jobId",jobId);
+ data.put("status",StatusService.Status.STARTED);
+ response.setData(data);
+ response.setSuccess();
+ return new JSONWithPadding( response, callback );
+ }
+
+ @RequireSystemAccess
+ @GET
+ @Path( "{applicationId}/job/{jobId}" )
+ public JSONWithPadding getStatus( @Context UriInfo ui,
+ @PathParam("applicationId") UUID applicationId,
+ @PathParam("jobId") UUID jobId,
+ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception{
+ final StatusService statusService = injector.getInstance(StatusService.class);
+
+ final ApiResponse response = createApiResponse();
+
+ response.setAction( "clear application" );
+
+ StatusService.JobStatus jobStatus = statusService.getStatus(applicationId, jobId).toBlocking().lastOrDefault(null);
+
+ Map<String,Object> data = new HashMap<>();
+ data.put("jobId",jobId);
+ data.put( "status", jobStatus.getStatus().toString() );
+ data.put( "metadata", jobStatus.getData() );
+ response.setData(data);
+ response.setSuccess();
+
+ return new JSONWithPadding( response, callback );
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/main/java/org/apache/usergrid/rest/system/DatabaseResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/system/DatabaseResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/system/DatabaseResource.java
new file mode 100644
index 0000000..f24bfc8
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/system/DatabaseResource.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.system;
+
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.ApiResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+
+import com.sun.jersey.api.json.JSONWithPadding;
+
+
+@Component
+@Scope( "singleton" )
+@Produces( {
+ MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+ "application/ecmascript", "text/jscript"
+} )
+public class DatabaseResource extends AbstractContextResource {
+
+ private static final Logger logger = LoggerFactory.getLogger( DatabaseResource.class );
+
+
+ public DatabaseResource() {
+ logger.info( "DatabaseResource initialized" );
+ }
+
+
+ @RequireSystemAccess
+ @PUT
+ @Path( "setup" )
+ public JSONWithPadding runDatabaseSetup( @Context UriInfo ui,
+ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+ throws Exception {
+
+ ApiResponse response = createApiResponse();
+ response.setAction( "cassandra setup" );
+
+ logger.info( "Setting up Cassandra" );
+
+
+ emf.setup();
+
+
+ response.setSuccess();
+
+ return new JSONWithPadding( response, callback );
+ }
+
+
+ @RequireSystemAccess
+ @PUT
+ @Path( "bootstrap" )
+ public JSONWithPadding runSystemSetup( @Context UriInfo ui,
+ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+ throws Exception {
+
+ ApiResponse response = createApiResponse();
+ response.setAction( "cassandra setup" );
+
+ logger.info( "Setting up Cassandra" );
+
+
+ emf.boostrap();
+ management.setup();
+
+ response.setSuccess();
+
+ return new JSONWithPadding( response, callback );
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/main/java/org/apache/usergrid/rest/system/QueueSystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/system/QueueSystemResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/system/QueueSystemResource.java
new file mode 100644
index 0000000..0721d89
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/system/QueueSystemResource.java
@@ -0,0 +1,78 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.rest.system;
+
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.sun.jersey.api.json.JSONWithPadding;
+import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
+import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * retrieves queue stats
+ */
+@Component
+@Scope( "singleton" )
+@Produces( {
+ MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+ "application/ecmascript", "text/jscript"
+} )
+public class QueueSystemResource extends AbstractContextResource {
+ private static final Logger logger = LoggerFactory.getLogger(QueueSystemResource.class);
+
+ public QueueSystemResource(){logger.info("queue resource initialized");}
+
+ /**
+ * Return queue depth of this Usergrid instance in JSON format.
+ *
+ * By Default this end-point will ignore errors but if you call it with ignore_status=false
+ * then it will return HTTP 500 if either the Entity store or the Index for the management
+ * application are in a bad state.
+ *
+ */
+ @GET
+ @RequireSystemAccess
+ @Path("size")
+ public JSONWithPadding getQueueDepth(
+ @QueryParam("callback") @DefaultValue("callback") String callback ) {
+
+ ApiResponse response = createApiResponse();
+ response.setAction( "get queue depth" );
+
+ AsyncEventService eventService = injector.getInstance(AsyncEventService.class);
+ ObjectNode node = JsonNodeFactory.instance.objectNode();
+
+ node.put("queueDepth", eventService.getQueueDepth());
+
+ response.setProperty( "data", node );
+
+ return new JSONWithPadding( response, callback );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
index 55623dd..44fa036 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
@@ -24,6 +24,7 @@ import org.apache.usergrid.rest.test.resource.model.Entity;
import org.apache.usergrid.rest.test.resource.model.QueryParameters;
import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.UUID;
import static org.junit.Assert.assertEquals;
@@ -63,7 +64,7 @@ public class SystemResourceIT extends AbstractRestIT {
queryParameters.addParam( "access_token", clientSetup.getSuperuserToken().getAccessToken() );
queryParameters.addParam("confirmApplicationName", this.clientSetup.getAppName());
- org.apache.usergrid.rest.test.resource.model.ApiResponse result = clientSetup.getRestClient().system().applications(this.clientSetup.getAppUuid()).delete( queryParameters);
+ org.apache.usergrid.rest.test.resource.model.ApiResponse result = clientSetup.getRestClient().system().getSubResource("applications/" + this.clientSetup.getAppUuid()).delete(false, true, queryParameters);
assertNotNull(result);
assertNotNull("ok", result.getStatus());
@@ -80,7 +81,7 @@ public class SystemResourceIT extends AbstractRestIT {
Thread.sleep(100);
}
}
- assertEquals(((LinkedHashMap)((LinkedHashMap) result.getData()).get("metadata")).get("count"), 10);
+ assertEquals(((LinkedHashMap) ((LinkedHashMap) result.getData()).get("metadata")).get("count"), 10);
}
@@ -88,9 +89,9 @@ public class SystemResourceIT extends AbstractRestIT {
@Test
public void testBoostrapAlreadyRun() {
QueryParameters queryParameters = new QueryParameters();
- queryParameters.addParam( "access_token", clientSetup.getSuperuserToken().getAccessToken() );
+ queryParameters.addParam("access_token", clientSetup.getSuperuserToken().getAccessToken());
- Entity result = clientSetup.getRestClient().system().database().bootstrap().put( queryParameters );
+ Entity result = clientSetup.getRestClient().system().database().bootstrap().put(queryParameters);
assertNotNull( result );
assertNotNull( "ok", ( String ) result.get( "status" ) );
@@ -98,6 +99,18 @@ public class SystemResourceIT extends AbstractRestIT {
result = clientSetup.getRestClient().system().database().bootstrap().put( queryParameters );
assertNotNull( result );
- assertNotNull( "ok", ( String ) result.get( "status" ) );
+ assertNotNull("ok", (String) result.get("status"));
+ }
+ @Test
+ public void testQueueDepth() {
+ QueryParameters queryParameters = new QueryParameters();
+ queryParameters.addParam("access_token", clientSetup.getSuperuserToken().getAccessToken());
+
+ Entity result = clientSetup.getRestClient().system().getSubResource("queue/size").get(Entity.class, queryParameters,false,true);
+
+ assertNotNull( result );
+ assertEquals(0, ((Map) result.get("data")).get("queueDepth"));
+
+
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
index 1a9c776..79ecb9e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
@@ -297,14 +297,21 @@ public class NamedResource implements UrlResource {
public <T> T get(Class<T> type,QueryParameters queryParameters) {
- return get( type, queryParameters, true );
+ return get(type, queryParameters, true);
}
-
public <T> T get(Class<T> type,QueryParameters queryParameters, boolean useToken) {
+ return get(type,queryParameters,useToken,false);
+ }
+ public <T> T get(Class<T> type,QueryParameters queryParameters, boolean useToken, boolean useSupertoken) {
WebResource resource = getResource(useToken);
if(queryParameters!=null) {
resource = addParametersToResource(resource, queryParameters);
}
+ if(useSupertoken) {
+ //added httpBasicauth filter to all setup calls because they all do verification this way.
+ HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter("superuser", "superpassword");
+ resource.addFilter(httpBasicAuthFilter);
+ }
GenericType<T> gt = new GenericType<>((Class) type);
return resource.type(MediaType.APPLICATION_JSON_TYPE)
.accept( MediaType.APPLICATION_JSON )
@@ -318,7 +325,7 @@ public class NamedResource implements UrlResource {
public ApiResponse post( boolean useToken, FormDataMultiPart multiPartForm ) {
WebResource resource = getResource( useToken );
- return resource.type( MediaType.MULTIPART_FORM_DATA_TYPE ).post( ApiResponse.class, multiPartForm );
+ return resource.type( MediaType.MULTIPART_FORM_DATA_TYPE ).post(ApiResponse.class, multiPartForm);
}
public ApiResponse post( FormDataMultiPart multiPartForm ) {
@@ -359,12 +366,29 @@ public class NamedResource implements UrlResource {
public ApiResponse delete( boolean useToken ) {
return getResource(useToken).delete(ApiResponse.class);
}
-
public ApiResponse delete( boolean useToken, QueryParameters queryParameters ) {
+ return delete(useToken,false,queryParameters);
+ }
+ public ApiResponse delete( boolean useToken, boolean useSupertoken, QueryParameters queryParameters ) {
WebResource resource = getResource(useToken);
if(queryParameters!=null) {
resource = addParametersToResource(resource, queryParameters);
}
- return resource.delete( ApiResponse.class );
+ if(useSupertoken) {
+ //added httpBasicauth filter to all setup calls because they all do verification this way.
+ HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter("superuser", "superpassword");
+ resource.addFilter(httpBasicAuthFilter);
+ }
+ return resource.delete(ApiResponse.class);
+ }
+
+
+
+ public ClientContext getContext(){
+ return context;
+ }
+
+ public NamedResource getSubResource(final String path){
+ return SubResource.getInstance(path,this);
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
index 8537251..2671ff2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
@@ -66,6 +66,11 @@ public class RootResource implements UrlResource {
return null;
}
+ @Override
+ public ClientContext getContext() {
+ return context;
+ }
+
/**
* Get the management resource
* @return
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SubResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SubResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SubResource.java
new file mode 100644
index 0000000..69c9aab
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SubResource.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.rest.test.resource.endpoints;
+
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
+/**
+ * Classy class class.
+ */
+public class SubResource extends NamedResource {
+
+ private SubResource(final String path, final ClientContext context, final UrlResource parent) {
+ super( path, context, parent );
+ }
+
+ public static NamedResource getInstance(final String path, final UrlResource parent ){
+ return new SubResource(path,parent.getContext(),parent);
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f04f50c1/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
index eb16d4d..b040aee 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
@@ -40,5 +40,11 @@ public interface UrlResource {
*/
public WebResource getResource();
+ /**
+ * get context
+ * @return
+ */
+ public ClientContext getContext();
+
}
[18/25] usergrid git commit: Merge branch 'two-dot-o-dev' of
https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1022
Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1022
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/e28be8fb
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/e28be8fb
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/e28be8fb
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: e28be8fb0c983d3b2a38a093582163df2351c058
Parents: f04f50c a4fa094
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 18 13:29:19 2015 -0400
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 18 13:29:19 2015 -0400
----------------------------------------------------------------------
.../org/apache/usergrid/tools/ExportAdmins.java | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
[05/25] usergrid git commit: add subscribe to entity verifier
Posted by sn...@apache.org.
add subscribe to entity verifier
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/8df05d12
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/8df05d12
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/8df05d12
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 8df05d121de0bcad74daccb1ca6b19fe73443a9e
Parents: 65bb208
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 15:39:20 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 15:39:20 2015 -0600
----------------------------------------------------------------------
.../pipeline/read/search/CandidateEntityFilter.java | 5 +++--
.../persistence/index/impl/EsIndexBufferConsumerImpl.java | 2 +-
.../usergrid/persistence/index/impl/IndexBufferConsumer.java | 2 ++
3 files changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/8df05d12/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
index c056b33..14c880f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
@@ -61,7 +61,8 @@ public class CandidateEntityFilter extends AbstractFilter<FilterResult<Candidate
@Inject
public CandidateEntityFilter( final EntityCollectionManagerFactory entityCollectionManagerFactory,
final EntityIndexFactory entityIndexFactory,
- final IndexLocationStrategyFactory indexLocationStrategyFactory) {
+ final IndexLocationStrategyFactory indexLocationStrategyFactory
+ ) {
this.entityCollectionManagerFactory = entityCollectionManagerFactory;
this.entityIndexFactory = entityIndexFactory;
this.indexLocationStrategyFactory = indexLocationStrategyFactory;
@@ -170,7 +171,7 @@ public class CandidateEntityFilter extends AbstractFilter<FilterResult<Candidate
validate( candidateResult );
}
- batch.execute();
+ batch.execute().subscribe();
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/8df05d12/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
index 4679483..06d63e1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicLong;
import com.codahale.metrics.Histogram;
import org.apache.usergrid.persistence.core.metrics.ObservableTimer;
+import org.apache.usergrid.persistence.index.EntityIndexBatch;
import org.elasticsearch.action.WriteConsistencyLevel;
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
@@ -93,7 +94,6 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
}
-
public Observable<IndexOperationMessage> put( IndexOperationMessage message ) {
Preconditions.checkNotNull(message, "Message cannot be null");
indexSizeCounter.inc(message.getDeIndexRequests().size());
http://git-wip-us.apache.org/repos/asf/usergrid/blob/8df05d12/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
index 20b60b7..8706def 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
@@ -20,6 +20,7 @@
package org.apache.usergrid.persistence.index.impl;
+import org.apache.usergrid.persistence.index.EntityIndexBatch;
import rx.Observable;
import java.util.List;
@@ -37,4 +38,5 @@ public interface IndexBufferConsumer {
* @return
*/
Observable<IndexOperationMessage> put(IndexOperationMessage message);
+
}
[19/25] usergrid git commit: Merge branch 'two-dot-o-dev' of
https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1022
Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1022
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/48391ac0
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/48391ac0
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/48391ac0
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 48391ac078ecf5ec3d2b42af424c4b3b234dc822
Parents: e28be8f 327ccc6
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 18 15:00:45 2015 -0400
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 18 15:00:45 2015 -0400
----------------------------------------------------------------------
.../usergrid/corepersistence/CoreModule.java | 51 +++++--
.../migration/CoreMigration.java | 45 ++----
.../migration/CoreMigrationPlugin.java | 38 +++--
.../migration/DeDupConnectionDataMigration.java | 93 ++++++++++++
.../migration/EntityTypeMappingMigration.java | 104 -------------
.../migration/MigrationModuleVersionPlugin.java | 5 -
.../corepersistence/migration/Versions.java | 31 ----
.../DeDupConnectionDataMigrationTest.java | 145 +++++++++++++++++++
.../migration/EntityTypeMappingMigrationIT.java | 125 ----------------
.../serialization/impl/SerializationModule.java | 4 +-
.../migration/CollectionMigrationPlugin.java | 8 +-
.../migration/MvccEntityDataMigrationImpl.java | 10 +-
...ctMvccEntityDataMigrationV1ToV3ImplTest.java | 39 +++--
.../core/astyanax/MultiRowColumnIterator.java | 2 +-
.../migration/data/AbstractMigrationPlugin.java | 17 +--
.../core/migration/data/DataMigration.java | 11 +-
.../migration/data/MigrationDataProvider.java | 2 +-
.../core/migration/data/MigrationPlugin.java | 4 +-
.../migration/data/TestProgressObserver.java | 10 +-
.../persistence/graph/guice/GraphModule.java | 4 +-
.../impl/migration/EdgeDataMigrationImpl.java | 12 +-
.../impl/migration/GraphMigrationPlugin.java | 8 +-
.../persistence/graph/GraphManagerIT.java | 6 +-
.../migration/EdgeDataMigrationImplTest.java | 59 ++++----
.../persistence/index/guice/IndexModule.java | 4 +-
.../index/migration/EsIndexMigrationPlugin.java | 8 +-
26 files changed, 418 insertions(+), 427 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/48391ac0/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/48391ac0/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
----------------------------------------------------------------------
[16/25] usergrid git commit: merge two-dot-o-dev
Posted by sn...@apache.org.
merge two-dot-o-dev
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/73dd687f
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/73dd687f
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/73dd687f
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 73dd687f787a34796c0abd56612f1175014bff46
Parents: 847c39f 61dd559
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Sep 17 15:43:36 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Sep 17 15:43:36 2015 -0600
----------------------------------------------------------------------
.../persistence/index/CandidateResult.java | 32 ++-
.../persistence/index/CandidateResults.java | 34 ++-
.../SearchRequestBuilderStrategyV2.java | 30 +--
.../usergrid/persistence/index/IndexEdge.java | 36 +--
.../index/IndexLocationStrategy.java | 30 +--
.../persistence/index/IndexRefreshCommand.java | 30 +--
.../usergrid/persistence/index/SearchType.java | 30 +--
.../usergrid/persistence/index/SearchTypes.java | 32 +--
.../persistence/index/SelectFieldMapping.java | 36 +--
.../persistence/index/impl/EntityField.java | 32 ++-
.../index/impl/EntityMappingParser.java | 35 ++-
.../index/impl/EsEntityIndexFactoryImpl.java | 29 ++-
.../index/impl/EsIndexCacheImpl.java | 29 ++-
.../persistence/index/impl/FailureMonitor.java | 30 ++-
.../index/impl/FailureMonitorImpl.java | 32 +--
.../persistence/index/impl/FieldParser.java | 36 +--
.../persistence/index/impl/GeoSortFields.java | 36 +--
.../persistence/index/impl/IndexCache.java | 30 +--
.../persistence/index/impl/IndexEdgeImpl.java | 36 +--
.../index/impl/IndexIdentifierv2Impl.java | 30 +--
.../persistence/index/impl/IndexProducer.java | 28 ++-
.../index/impl/IndexRefreshCommandImpl.java | 30 +--
.../index/impl/NoOpFilterBuilder.java | 32 ++-
.../index/impl/NoOpQueryBuilder.java | 32 ++-
.../impl/SearchRequestBuilderStrategy.java | 30 +--
.../persistence/index/impl/SortBuilder.java | 36 +--
.../EsIndexMappingMigrationPlugin.java | 30 ++-
.../index/migration/IndexDataVersions.java | 30 +--
.../persistence/index/query/ParsedQuery.java | 36 +--
.../index/query/ParsedQueryBuilder.java | 36 +--
.../persistence/index/query/SortPredicate.java | 36 +--
.../persistence/index/usergrid-mappings.json | 5 -
.../index/impl/EntityToMapConverterTest.java | 36 +--
.../impl/EsIndexMappingMigrationPluginTest.java | 30 +--
.../persistence/index/impl/EsRunner.java | 32 +--
.../persistence/index/impl/GeoPagingTest.java | 36 +--
.../index/impl/TestIndexIdentifier.java | 30 +--
.../management/AppInfoMigrationPlugin.java | 234 +++++++++----------
38 files changed, 683 insertions(+), 721 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/73dd687f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/73dd687f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
index 8f3ab79,0000000..e653bc3
mode 100644,000000..100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
@@@ -1,41 -1,0 +1,39 @@@
+/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements. The ASF licenses this file to You
++ * under the Apache License, Version 2.0 (the "License"); you may not
++ * use this file except in compliance with the License.
++ * You may obtain a copy of the License at
+ *
- * * Licensed to the Apache Software Foundation (ASF) under one or more
- * * contributor license agreements. The ASF licenses this file to You
- * * under the Apache License, Version 2.0 (the "License"); you may not
- * * use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License. For additional information regarding
- * * copyright in this work, please see the NOTICE file in the top level
- * * directory of this distribution.
++ * http://www.apache.org/licenses/LICENSE-2.0
+ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License. For additional information regarding
++ * copyright in this work, please see the NOTICE file in the top level
++ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.impl;
+
+
+import org.apache.usergrid.persistence.index.EntityIndexBatch;
+import rx.Observable;
+
+
+/**
+ * Buffer index requests
+ */
+public interface IndexProducer {
+
+
+ /**
+ * Put this operation into our collapsing bufer
+ * @param message
+ * @return
+ */
+ Observable<IndexOperationMessage> put(EntityIndexBatch message);
+ Observable<IndexOperationMessage> put(IndexOperationMessage message);
+
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/73dd687f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/73dd687f/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
----------------------------------------------------------------------
[06/25] usergrid git commit: change consumer to producer
Posted by sn...@apache.org.
change consumer to producer
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/7450c94e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/7450c94e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/7450c94e
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 7450c94e65623adf05dc3a69761e9dda10ae44fd
Parents: 8df05d1
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 16:17:13 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 16:17:13 2015 -0600
----------------------------------------------------------------------
.../persistence/index/guice/IndexModule.java | 2 +-
.../index/impl/EsEntityIndexBatchImpl.java | 4 +-
.../index/impl/EsEntityIndexFactoryImpl.java | 8 +-
.../index/impl/EsEntityIndexImpl.java | 6 +-
.../index/impl/EsIndexBufferConsumerImpl.java | 218 -------------------
.../index/impl/EsIndexProducerImpl.java | 211 ++++++++++++++++++
.../index/impl/IndexBufferConsumer.java | 42 ----
.../persistence/index/impl/IndexProducer.java | 39 ++++
.../index/impl/IndexRefreshCommandImpl.java | 5 +-
9 files changed, 261 insertions(+), 274 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
index d03bbf8..ab59b93 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
@@ -52,7 +52,7 @@ public abstract class IndexModule extends AbstractModule {
bind(IndexCache.class).to(EsIndexCacheImpl.class);
bind(IndexRefreshCommand.class).to(IndexRefreshCommandImpl.class);
- bind(IndexBufferConsumer.class).to(EsIndexBufferConsumerImpl.class).asEagerSingleton();
+ bind(IndexProducer.class).to(EsIndexProducerImpl.class).asEagerSingleton();
//wire up the edg migration. A no-op ATM, but retained for future development
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index c11feed..64a1c6a 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -41,7 +41,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
private final IndexAlias alias;
private final IndexLocationStrategy indexLocationStrategy;
- private final IndexBufferConsumer indexBatchBufferProducer;
+ private final IndexProducer indexBatchBufferProducer;
private final EntityIndex entityIndex;
private final ApplicationScope applicationScope;
@@ -49,7 +49,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
public EsEntityIndexBatchImpl( final IndexLocationStrategy locationStrategy,
- final IndexBufferConsumer indexBatchBufferProducer,
+ final IndexProducer indexBatchBufferProducer,
final EntityIndex entityIndex
) {
this.indexLocationStrategy = locationStrategy;
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
index 5f6b4fd..cd47a86 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
@@ -38,7 +38,7 @@ public class EsEntityIndexFactoryImpl implements EntityIndexFactory{
private final IndexFig config;
private final IndexCache indexCache;
private final EsProvider provider;
- private final IndexBufferConsumer indexBufferConsumer;
+ private final IndexProducer indexProducer;
private final MetricsFactory metricsFactory;
private final IndexRefreshCommand refreshCommand;
@@ -51,7 +51,7 @@ public class EsEntityIndexFactoryImpl implements EntityIndexFactory{
config,
refreshCommand,
metricsFactory,
- indexBufferConsumer,
+ indexProducer,
locationStrategy
);
index.initialize();
@@ -63,7 +63,7 @@ public class EsEntityIndexFactoryImpl implements EntityIndexFactory{
public EsEntityIndexFactoryImpl( final IndexFig indexFig,
final IndexCache indexCache,
final EsProvider provider,
- final IndexBufferConsumer indexBufferConsumer,
+ final IndexProducer indexProducer,
final MetricsFactory metricsFactory,
final IndexRefreshCommand refreshCommand
@@ -71,7 +71,7 @@ public class EsEntityIndexFactoryImpl implements EntityIndexFactory{
this.config = indexFig;
this.indexCache = indexCache;
this.provider = provider;
- this.indexBufferConsumer = indexBufferConsumer;
+ this.indexProducer = indexProducer;
this.metricsFactory = metricsFactory;
this.refreshCommand = refreshCommand;
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 1c63a7b..6317a69 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -63,8 +63,6 @@ import org.elasticsearch.index.query.*;
import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
-import org.elasticsearch.search.aggregations.Aggregation;
-import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.metrics.sum.SumBuilder;
import org.slf4j.Logger;
@@ -118,7 +116,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
private final SearchRequestBuilderStrategyV2 searchRequestBuilderStrategyV2;
private final int cursorTimeout;
private final long queryTimeout;
- private final IndexBufferConsumer indexBatchBufferProducer;
+ private final IndexProducer indexBatchBufferProducer;
private final FailureMonitorImpl failureMonitor;
private final Timer aggregationTimer;
@@ -133,7 +131,7 @@ public class EsEntityIndexImpl implements EntityIndex,VersionedData {
final IndexFig indexFig,
final IndexRefreshCommand indexRefreshCommand,
final MetricsFactory metricsFactory,
- final IndexBufferConsumer indexBatchBufferProducer,
+ final IndexProducer indexBatchBufferProducer,
final IndexLocationStrategy indexLocationStrategy
) {
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
deleted file mode 100644
index 06d63e1..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- *
- * * Licensed to the Apache Software Foundation (ASF) under one or more
- * * contributor license agreements. The ASF licenses this file to You
- * * under the Apache License, Version 2.0 (the "License"); you may not
- * * use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License. For additional information regarding
- * * copyright in this work, please see the NOTICE file in the top level
- * * directory of this distribution.
- *
- */
-package org.apache.usergrid.persistence.index.impl;
-
-
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import com.codahale.metrics.Histogram;
-import org.apache.usergrid.persistence.core.metrics.ObservableTimer;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.elasticsearch.action.WriteConsistencyLevel;
-import org.elasticsearch.action.bulk.BulkItemResponse;
-import org.elasticsearch.action.bulk.BulkRequestBuilder;
-import org.elasticsearch.action.bulk.BulkResponse;
-import org.elasticsearch.client.Client;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
-import org.apache.usergrid.persistence.index.IndexFig;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.Timer;
-import com.google.common.base.Preconditions;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-import rx.Observable;
-import rx.Subscriber;
-import rx.schedulers.Schedulers;
-
-
-/**
- * Consumer for IndexOperationMessages
- */
-@Singleton
-public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
- private static final Logger log = LoggerFactory.getLogger( EsIndexBufferConsumerImpl.class );
-
- private final IndexFig config;
- private final FailureMonitorImpl failureMonitor;
- private final Client client;
- private final Timer flushTimer;
- private final IndexFig indexFig;
- private final Counter indexSizeCounter;
- private final Histogram roundtripTimer;
- private final Timer indexTimer;
-
-
- private AtomicLong inFlight = new AtomicLong();
-
-
- @Inject
- public EsIndexBufferConsumerImpl( final IndexFig config, final EsProvider provider,
- final MetricsFactory metricsFactory, final IndexFig indexFig ) {
- this.flushTimer = metricsFactory.getTimer(EsIndexBufferConsumerImpl.class, "index_buffer.flush");
- this.indexSizeCounter = metricsFactory.getCounter(EsIndexBufferConsumerImpl.class, "index_buffer.size");
- this.roundtripTimer = metricsFactory.getHistogram(EsIndexBufferConsumerImpl.class, "index_buffer.message_cycle");
-
- //wire up the gauge of inflight messages
- metricsFactory.addGauge(EsIndexBufferConsumerImpl.class, "index_buffer.inflight", () -> inFlight.longValue());
-
-
- this.indexTimer = metricsFactory.getTimer( EsIndexBufferConsumerImpl.class, "index" );
-
- this.config = config;
- this.failureMonitor = new FailureMonitorImpl(config, provider);
- this.client = provider.getClient();
- this.indexFig = indexFig;
-
-
- //batch up sets of some size and send them in batch
-
- }
-
- public Observable<IndexOperationMessage> put( IndexOperationMessage message ) {
- Preconditions.checkNotNull(message, "Message cannot be null");
- indexSizeCounter.inc(message.getDeIndexRequests().size());
- indexSizeCounter.inc(message.getIndexRequests().size());
- return processBatch(message);
- }
-
-
- /**
- * Process the buffer of batches
- * @param batch
- * @return
- */
- private Observable<IndexOperationMessage> processBatch( final IndexOperationMessage batch ) {
-
- //take our stream of batches, then stream then into individual ops for consumption on ES
- final Set<IndexOperation> indexOperationSet = batch.getIndexRequests();
- final Set<DeIndexOperation> deIndexOperationSet = batch.getDeIndexRequests();
-
- final int indexOperationSetSize = indexOperationSet.size();
- final int deIndexOperationSetSize = deIndexOperationSet.size();
-
- log.debug("Emitting {} add and {} remove operations", indexOperationSetSize, deIndexOperationSetSize);
-
- indexSizeCounter.dec(indexOperationSetSize);
- indexSizeCounter.dec(deIndexOperationSetSize);
-
- final Observable<IndexOperation> index = Observable.from(batch.getIndexRequests());
- final Observable<DeIndexOperation> deIndex = Observable.from(batch.getDeIndexRequests());
-
- final Observable<BatchOperation> batchOps = Observable.merge(index, deIndex);
-
- //buffer into the max size we can send ES and fire them all off until we're completed
- final Observable<BulkRequestBuilder> requests = batchOps.buffer(indexFig.getIndexBatchSize())
- //flatten the buffer into a single batch execution
- .flatMap(individualOps -> Observable.from(individualOps)
- //collect them
- .collect(() -> initRequest(), (bulkRequestBuilder, batchOperation) -> {
- log.debug("adding operation {} to bulkRequestBuilder {}", batchOperation, bulkRequestBuilder);
- batchOperation.doOperation(client, bulkRequestBuilder);
- }))
- //write them
- .doOnNext(bulkRequestBuilder -> sendRequest(bulkRequestBuilder));
-
-
- //now that we've processed them all, ack the futures after our last batch comes through
- final Observable<IndexOperationMessage> processedIndexOperations =
- requests.lastOrDefault(null).flatMap(lastRequest -> {
- if (lastRequest != null) {
- return Observable.just(batch);
- } else {
- return Observable.empty();
- }
- });
-
- //subscribe to the operations that generate requests on a new thread so that we can execute them quickly
- //mark this as done
- return processedIndexOperations.doOnNext(processedIndexOp -> {
- roundtripTimer.update(System.currentTimeMillis() - processedIndexOp.getCreationTime());
- });
- }
-
-
- /*
-
- /**
- * initialize request
- */
- private BulkRequestBuilder initRequest() {
- BulkRequestBuilder bulkRequest = client.prepareBulk();
- bulkRequest.setConsistencyLevel( WriteConsistencyLevel.fromString( config.getWriteConsistencyLevel() ) );
- bulkRequest.setRefresh( config.isForcedRefresh() );
- return bulkRequest;
- }
-
-
- /**
- * send bulk request
- */
- private void sendRequest( BulkRequestBuilder bulkRequest ) {
- //nothing to do, we haven't added anything to the index
- if ( bulkRequest.numberOfActions() == 0 ) {
- return;
- }
-
- final BulkResponse responses;
-
-
- final Timer.Context timer = indexTimer.time();
-
- try {
- responses = bulkRequest.execute().actionGet( );
- } catch ( Throwable t ) {
- log.error( "Unable to communicate with elasticsearch" );
- failureMonitor.fail( "Unable to execute batch", t );
- throw t;
- }finally{
- timer.stop();
- }
-
- failureMonitor.success();
-
- boolean error = false;
-
- for ( BulkItemResponse response : responses ) {
-
- if ( response.isFailed() ) {
- // log error and continue processing
- log.error( "Unable to index id={}, type={}, index={}, failureMessage={} ", response.getId(),
- response.getType(), response.getIndex(), response.getFailureMessage() );
-
- error = true;
- }
- }
-
- if ( error ) {
- throw new RuntimeException(
- "Error during processing of bulk index operations one of the responses failed. Check previous log "
- + "entries" );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
new file mode 100644
index 0000000..efce823
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexProducerImpl.java
@@ -0,0 +1,211 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.persistence.index.impl;
+
+
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+
+import com.codahale.metrics.Histogram;
+import org.elasticsearch.action.WriteConsistencyLevel;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkRequestBuilder;
+import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.client.Client;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
+import org.apache.usergrid.persistence.index.IndexFig;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Timer;
+import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+import rx.Observable;
+
+
+/**
+ * Consumer for IndexOperationMessages
+ */
+@Singleton
+public class EsIndexProducerImpl implements IndexProducer {
+ private static final Logger log = LoggerFactory.getLogger( EsIndexProducerImpl.class );
+
+ private final IndexFig config;
+ private final FailureMonitorImpl failureMonitor;
+ private final Client client;
+ private final Timer flushTimer;
+ private final IndexFig indexFig;
+ private final Counter indexSizeCounter;
+ private final Histogram roundtripTimer;
+ private final Timer indexTimer;
+
+
+ private AtomicLong inFlight = new AtomicLong();
+
+
+ @Inject
+ public EsIndexProducerImpl(final IndexFig config, final EsProvider provider,
+ final MetricsFactory metricsFactory, final IndexFig indexFig) {
+ this.flushTimer = metricsFactory.getTimer(EsIndexProducerImpl.class, "index_buffer.flush");
+ this.indexSizeCounter = metricsFactory.getCounter(EsIndexProducerImpl.class, "index_buffer.size");
+ this.roundtripTimer = metricsFactory.getHistogram(EsIndexProducerImpl.class, "index_buffer.message_cycle");
+
+ //wire up the gauge of inflight messages
+ metricsFactory.addGauge(EsIndexProducerImpl.class, "index_buffer.inflight", () -> inFlight.longValue());
+
+
+ this.indexTimer = metricsFactory.getTimer( EsIndexProducerImpl.class, "index" );
+
+ this.config = config;
+ this.failureMonitor = new FailureMonitorImpl(config, provider);
+ this.client = provider.getClient();
+ this.indexFig = indexFig;
+
+
+ //batch up sets of some size and send them in batch
+
+ }
+
+ public Observable<IndexOperationMessage> put( IndexOperationMessage message ) {
+ Preconditions.checkNotNull(message, "Message cannot be null");
+ indexSizeCounter.inc(message.getDeIndexRequests().size());
+ indexSizeCounter.inc(message.getIndexRequests().size());
+ return processBatch(message);
+ }
+
+
+ /**
+ * Process the buffer of batches
+ * @param batch
+ * @return
+ */
+ private Observable<IndexOperationMessage> processBatch( final IndexOperationMessage batch ) {
+
+ //take our stream of batches, then stream then into individual ops for consumption on ES
+ final Set<IndexOperation> indexOperationSet = batch.getIndexRequests();
+ final Set<DeIndexOperation> deIndexOperationSet = batch.getDeIndexRequests();
+
+ final int indexOperationSetSize = indexOperationSet.size();
+ final int deIndexOperationSetSize = deIndexOperationSet.size();
+
+ log.debug("Emitting {} add and {} remove operations", indexOperationSetSize, deIndexOperationSetSize);
+
+ indexSizeCounter.dec(indexOperationSetSize);
+ indexSizeCounter.dec(deIndexOperationSetSize);
+
+ final Observable<IndexOperation> index = Observable.from(batch.getIndexRequests());
+ final Observable<DeIndexOperation> deIndex = Observable.from(batch.getDeIndexRequests());
+
+ final Observable<BatchOperation> batchOps = Observable.merge(index, deIndex);
+
+ //buffer into the max size we can send ES and fire them all off until we're completed
+ final Observable<BulkRequestBuilder> requests = batchOps.buffer(indexFig.getIndexBatchSize())
+ //flatten the buffer into a single batch execution
+ .flatMap(individualOps -> Observable.from(individualOps)
+ //collect them
+ .collect(() -> initRequest(), (bulkRequestBuilder, batchOperation) -> {
+ log.debug("adding operation {} to bulkRequestBuilder {}", batchOperation, bulkRequestBuilder);
+ batchOperation.doOperation(client, bulkRequestBuilder);
+ }))
+ //write them
+ .doOnNext(bulkRequestBuilder -> sendRequest(bulkRequestBuilder));
+
+
+ //now that we've processed them all, ack the futures after our last batch comes through
+ final Observable<IndexOperationMessage> processedIndexOperations =
+ requests.lastOrDefault(null).flatMap(lastRequest -> {
+ if (lastRequest != null) {
+ return Observable.just(batch);
+ } else {
+ return Observable.empty();
+ }
+ });
+
+ //subscribe to the operations that generate requests on a new thread so that we can execute them quickly
+ //mark this as done
+ return processedIndexOperations.doOnNext(processedIndexOp -> {
+ roundtripTimer.update(System.currentTimeMillis() - processedIndexOp.getCreationTime());
+ });
+ }
+
+
+ /*
+
+ /**
+ * initialize request
+ */
+ private BulkRequestBuilder initRequest() {
+ BulkRequestBuilder bulkRequest = client.prepareBulk();
+ bulkRequest.setConsistencyLevel( WriteConsistencyLevel.fromString( config.getWriteConsistencyLevel() ) );
+ bulkRequest.setRefresh( config.isForcedRefresh() );
+ return bulkRequest;
+ }
+
+
+ /**
+ * send bulk request
+ */
+ private void sendRequest( BulkRequestBuilder bulkRequest ) {
+ //nothing to do, we haven't added anything to the index
+ if ( bulkRequest.numberOfActions() == 0 ) {
+ return;
+ }
+
+ final BulkResponse responses;
+
+
+ final Timer.Context timer = indexTimer.time();
+
+ try {
+ responses = bulkRequest.execute().actionGet( );
+ } catch ( Throwable t ) {
+ log.error( "Unable to communicate with elasticsearch" );
+ failureMonitor.fail( "Unable to execute batch", t );
+ throw t;
+ }finally{
+ timer.stop();
+ }
+
+ failureMonitor.success();
+
+ boolean error = false;
+
+ for ( BulkItemResponse response : responses ) {
+
+ if ( response.isFailed() ) {
+ // log error and continue processing
+ log.error( "Unable to index id={}, type={}, index={}, failureMessage={} ", response.getId(),
+ response.getType(), response.getIndex(), response.getFailureMessage() );
+
+ error = true;
+ }
+ }
+
+ if ( error ) {
+ throw new RuntimeException(
+ "Error during processing of bulk index operations one of the responses failed. Check previous log "
+ + "entries" );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
deleted file mode 100644
index 8706def..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * * Licensed to the Apache Software Foundation (ASF) under one or more
- * * contributor license agreements. The ASF licenses this file to You
- * * under the Apache License, Version 2.0 (the "License"); you may not
- * * use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License. For additional information regarding
- * * copyright in this work, please see the NOTICE file in the top level
- * * directory of this distribution.
- *
- */
-package org.apache.usergrid.persistence.index.impl;
-
-
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import rx.Observable;
-
-import java.util.List;
-
-
-/**
- * Buffer index requests
- */
-public interface IndexBufferConsumer {
-
-
- /**
- * Put this operation into our collapsing bufer
- * @param message
- * @return
- */
- Observable<IndexOperationMessage> put(IndexOperationMessage message);
-
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
new file mode 100644
index 0000000..e18ac50
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexProducer.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.persistence.index.impl;
+
+
+import rx.Observable;
+
+
+/**
+ * Buffer index requests
+ */
+public interface IndexProducer {
+
+
+ /**
+ * Put this operation into our collapsing bufer
+ * @param message
+ * @return
+ */
+ Observable<IndexOperationMessage> put(IndexOperationMessage message);
+
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/7450c94e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
index 0b749a9..04712a4 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
@@ -20,7 +20,6 @@
package org.apache.usergrid.persistence.index.impl;
-import java.util.Collections;
import java.util.Map;
import java.util.UUID;
@@ -58,7 +57,7 @@ public class IndexRefreshCommandImpl implements IndexRefreshCommand {
private final IndexCache indexCache;
private final EsProvider esProvider;
- private final IndexBufferConsumer producer;
+ private final IndexProducer producer;
private final IndexFig indexFig;
private final Timer timer;
@@ -66,7 +65,7 @@ public class IndexRefreshCommandImpl implements IndexRefreshCommand {
@Inject
public IndexRefreshCommandImpl(
final EsProvider esProvider,
- final IndexBufferConsumer producer,
+ final IndexProducer producer,
final IndexFig indexFig,
final MetricsFactory metricsFactory,
final IndexCache indexCache ) {
[03/25] usergrid git commit: remove threading
Posted by sn...@apache.org.
remove threading
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/aa57e24b
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/aa57e24b
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/aa57e24b
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: aa57e24bc70c4dd9c1be4e229ce6cd06cbebe3ea
Parents: 8d6ad80
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 13:45:08 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 13:45:08 2015 -0600
----------------------------------------------------------------------
.../core/future/FutureObservable.java | 44 -------------
.../persistence/index/EntityIndexBatch.java | 1 -
.../index/impl/EsIndexBufferConsumerImpl.java | 65 +-------------------
.../index/impl/IndexOperationMessage.java | 18 ------
4 files changed, 1 insertion(+), 127 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/aa57e24b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/future/FutureObservable.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/future/FutureObservable.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/future/FutureObservable.java
deleted file mode 100644
index 06eed4d..0000000
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/future/FutureObservable.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.core.future;
-
-
-import rx.Observable;
-
-import java.util.concurrent.FutureTask;
-
-
-/**
- * Future without the exception nastiness
- */
-public class FutureObservable<T> {
-
- private final FutureTask<T> future;
-
-
- public FutureObservable(final T returnVal) {
- future = new FutureTask<>( () -> returnVal );
- }
-
- public void done() {
- future.run();
- }
-
- public Observable<T> observable() {
- return Observable.from(future);
- }
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/aa57e24b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
index 85b234a..d1b076d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
@@ -20,7 +20,6 @@ package org.apache.usergrid.persistence.index;/*
import java.util.UUID;
-import org.apache.usergrid.persistence.core.future.FutureObservable;
import org.apache.usergrid.persistence.index.impl.IndexOperationMessage;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
http://git-wip-us.apache.org/repos/asf/usergrid/blob/aa57e24b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
index ca8cb82..2066b51 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
@@ -35,7 +35,6 @@ import org.elasticsearch.client.Client;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.usergrid.persistence.core.future.FutureObservable;
import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
import org.apache.usergrid.persistence.index.IndexFig;
@@ -64,8 +63,6 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
private final Timer flushTimer;
private final IndexFig indexFig;
private final Counter indexSizeCounter;
- private final Timer offerTimer;
- private final BufferProducer bufferProducer;
private final Histogram roundtripTimer;
private final Timer indexTimer;
@@ -78,7 +75,6 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
final MetricsFactory metricsFactory, final IndexFig indexFig ) {
this.flushTimer = metricsFactory.getTimer(EsIndexBufferConsumerImpl.class, "index_buffer.flush");
this.indexSizeCounter = metricsFactory.getCounter(EsIndexBufferConsumerImpl.class, "index_buffer.size");
- this.offerTimer = metricsFactory.getTimer(EsIndexBufferConsumerImpl.class, "index_buffer.producer");
this.roundtripTimer = metricsFactory.getHistogram(EsIndexBufferConsumerImpl.class, "index_buffer.message_cycle");
//wire up the gauge of inflight messages
@@ -92,11 +88,9 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
this.client = provider.getClient();
this.indexFig = indexFig;
- this.bufferProducer = new BufferProducer();
//batch up sets of some size and send them in batch
- startSubscription();
}
@@ -104,34 +98,8 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
Preconditions.checkNotNull(message, "Message cannot be null");
indexSizeCounter.inc(message.getDeIndexRequests().size());
indexSizeCounter.inc(message.getIndexRequests().size());
- Timer.Context time = offerTimer.time();
- bufferProducer.send(message);
- time.stop();
- return message.observable();
- }
-
-
- /**
- * Start the subscription
- */
- private void startSubscription() {
-
- //buffer on our new thread with a timeout
- final Observable<IndexOperationMessage> observable = Observable.create(bufferProducer);
- observable.subscribeOn(Schedulers.io()).flatMap(indexOpBuffer -> {
-
- //hand off to processor in new observable thread so we can continue to buffer faster
- return Observable.just(indexOpBuffer).flatMap(
- indexOpBufferObservable -> ObservableTimer.time(processBatch(indexOpBufferObservable), flushTimer)
- )
-
- //use the I/O scheduler for thread re-use and efficiency in context switching then use our concurrent
- // flatmap count or higher throughput of batches once buffered
- .subscribeOn(Schedulers.io());
- }, indexFig.getIndexFlushWorkerCount())
- //start in the background
- .subscribe();
+ return processBatch(message);
}
@@ -142,10 +110,7 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
*/
private Observable<IndexOperationMessage> processBatch( final IndexOperationMessage batch ) {
-
//take our stream of batches, then stream then into individual ops for consumption on ES
-
-
final Set<IndexOperation> indexOperationSet = batch.getIndexRequests();
final Set<DeIndexOperation> deIndexOperationSet = batch.getDeIndexRequests();
@@ -188,7 +153,6 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
//subscribe to the operations that generate requests on a new thread so that we can execute them quickly
//mark this as done
return processedIndexOperations.doOnNext(processedIndexOp -> {
- processedIndexOp.done();
roundtripTimer.update(System.currentTimeMillis() - processedIndexOp.getCreationTime());
});
}
@@ -253,31 +217,4 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
+ "entries" );
}
}
-
-
- public static class BufferProducer implements Observable.OnSubscribe<IndexOperationMessage> {
-
- private Subscriber<? super IndexOperationMessage> subscriber;
-
-
- /**
- * Send the data through the buffer
- */
- public void send( final IndexOperationMessage indexOps ) {
- try {
- subscriber.onNext( indexOps );
- }catch(Exception e){
- //re-throws so the caller can determine failover
- log.error( "Unable to process message for indexOp {}, error follows.", indexOps, e );
- throw e;
- }
- }
-
-
- @Override
- public void call( final Subscriber<? super IndexOperationMessage> subscriber ) {
- //just assigns for later use, doesn't do anything else
- this.subscriber = subscriber;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/aa57e24b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperationMessage.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperationMessage.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperationMessage.java
index 0a49626..bd2bec8 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperationMessage.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperationMessage.java
@@ -24,10 +24,7 @@ import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
-import org.apache.usergrid.persistence.core.future.FutureObservable;
-
import com.fasterxml.jackson.annotation.JsonIgnore;
-import rx.Observable;
/**
@@ -40,13 +37,11 @@ public class IndexOperationMessage implements Serializable {
private long creationTime;
- private final FutureObservable<IndexOperationMessage> containerFuture;
public IndexOperationMessage() {
this.indexRequests = new HashSet<>();
this.deIndexRequests = new HashSet<>();
- this.containerFuture = new FutureObservable<>( this );
this.creationTime = System.currentTimeMillis();
}
@@ -78,15 +73,6 @@ public class IndexOperationMessage implements Serializable {
return indexRequests.isEmpty() && deIndexRequests.isEmpty();
}
- /**
- * return the promise
- */
- @JsonIgnore
- public Observable<IndexOperationMessage> observable() {
- return containerFuture.observable();
- }
-
-
@Override
public boolean equals( final Object o ) {
if ( this == o ) {
@@ -116,10 +102,6 @@ public class IndexOperationMessage implements Serializable {
return result;
}
- public void done() {
- //if this has been serialized, it could be null. don't NPE if it is, there's nothing to ack
- containerFuture.done();
- }
public long getCreationTime() {
return creationTime;
[13/25] usergrid git commit: test delete groups. still 1 failing
Posted by sn...@apache.org.
test delete groups. still 1 failing
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/1ad074f1
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/1ad074f1
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/1ad074f1
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 1ad074f1cc50a0ab5757223617e6add6296351d4
Parents: f91f4e4
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 12:40:05 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 12:40:05 2015 -0600
----------------------------------------------------------------------
.../org/apache/usergrid/persistence/CollectionIT.java | 10 +++++++---
.../applications/collection/groups/GroupResourceIT.java | 5 +++--
2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/1ad074f1/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index cc948ac..1c67cc7 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -443,10 +443,14 @@ public class CollectionIT extends AbstractCoreIT {
Results r = em.searchCollectionConsistent( group, "users", query.withResultsLevel( Level.LINKED_PROPERTIES ),1 );
- LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
- assertEquals( 1, r.size() );
+ LOG.info(JsonUtils.mapToFormattedJsonString(r.getEntities()));
+ assertEquals(1, r.size());
+ assertTrue(r.getEntities().get(0).getUuid().equals(user1.getUuid()));
- em.removeFromCollection( user1, "groups", group );
+ em.removeFromCollection(user1, "groups", group);
+ r = em.searchCollection(user1,"groups",Query.all());
+ List<Entity> entities = r.getEntities();
+ assertTrue(entities.size()==0);
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/1ad074f1/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index bcf0962..a1bd03c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -258,7 +258,7 @@ public class GroupResourceIT extends AbstractRestIT {
*
*/
@Test
- public void addRemoveRoleGroup() throws IOException {
+ public void addRemoveRoleGroup() throws Exception {
//1. create a group
String groupName = "testgroup";
@@ -298,10 +298,11 @@ public class GroupResourceIT extends AbstractRestIT {
//8. delete the role
this.app().collection("role").entity(role).delete();
this.refreshIndex();
+ Thread.sleep(5000);
//9. do a GET to make sure the role was deleted
try {
- this.app().collection("role").entity(role).get();
+ Entity entity1 = this.app().collection("role").entity(role).get();
fail("Entity still exists");
} catch (UniformInterfaceException e) {
//verify the correct error was returned
[02/25] usergrid git commit: remove batch consumer
Posted by sn...@apache.org.
remove batch consumer
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/8d6ad802
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/8d6ad802
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/8d6ad802
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 8d6ad802f7884eee3b3b511d579ecb144d925aeb
Parents: 9d22a91
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 13:14:08 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 13:14:08 2015 -0600
----------------------------------------------------------------------
.../java/org/apache/usergrid/persistence/index/IndexFig.java | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/8d6ad802/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
index db1ef3d..4f35730 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
@@ -48,10 +48,6 @@ public interface IndexFig extends GuicyFig {
String ELASTICSEARCH_FORCE_REFRESH = "elasticsearch.force_refresh";
- String INDEX_BUFFER_SIZE = "elasticsearch.buffer_size";
-
- String INDEX_BUFFER_TIMEOUT = "elasticsearch.buffer_timeout";
-
String INDEX_BATCH_SIZE = "elasticsearch.batch_size";
String INDEX_WRITE_CONSISTENCY_LEVEL = "elasticsearch.write_consistency_level";
[21/25] usergrid git commit: merge from 1022
Posted by sn...@apache.org.
merge from 1022
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/684bf2af
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/684bf2af
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/684bf2af
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 684bf2afdc0a8c1dec271736e03b1b9ecb586beb
Parents: a2389e6 549be61
Author: Shawn Feldman <sf...@apache.org>
Authored: Sun Sep 20 18:02:51 2015 -0400
Committer: Shawn Feldman <sf...@apache.org>
Committed: Sun Sep 20 18:02:51 2015 -0400
----------------------------------------------------------------------
.../usergrid/corepersistence/CoreModule.java | 4 -
.../corepersistence/CpEntityManager.java | 31 +-
.../corepersistence/CpRelationManager.java | 27 +-
.../asyncevents/EventBuilderImpl.java | 44 +--
.../corepersistence/index/IndexServiceImpl.java | 26 +-
.../read/search/CandidateEntityFilter.java | 15 +-
.../pipeline/read/search/CandidateIdFilter.java | 14 +-
.../usergrid/persistence/EntityManager.java | 2 +
.../corepersistence/StaleIndexCleanupTest.java | 14 +-
.../usergrid/persistence/CollectionIT.java | 10 +-
.../usergrid/persistence/PermissionsIT.java | 7 +-
.../core/future/FutureObservable.java | 44 ---
.../persistence/index/EntityIndexBatch.java | 8 +-
.../usergrid/persistence/index/IndexFig.java | 18 --
.../persistence/index/guice/IndexModule.java | 2 +-
.../index/impl/EsEntityIndexBatchImpl.java | 21 +-
.../index/impl/EsEntityIndexFactoryImpl.java | 8 +-
.../index/impl/EsEntityIndexImpl.java | 6 +-
.../index/impl/EsIndexBufferConsumerImpl.java | 286 -------------------
.../index/impl/EsIndexProducerImpl.java | 218 ++++++++++++++
.../index/impl/IndexBufferConsumer.java | 36 ---
.../index/impl/IndexOperationMessage.java | 18 --
.../persistence/index/impl/IndexProducer.java | 39 +++
.../index/impl/IndexRefreshCommandImpl.java | 4 +-
.../persistence/index/impl/EntityIndexTest.java | 66 ++---
.../persistence/index/impl/GeoPagingTest.java | 5 +-
.../index/impl/IndexLoadTestsIT.java | 6 +-
.../usergrid/rest/ApplicationsResource.java | 166 -----------
.../apache/usergrid/rest/DatabaseResource.java | 99 -------
.../apache/usergrid/rest/SystemResource.java | 19 +-
.../rest/system/ApplicationsResource.java | 168 +++++++++++
.../usergrid/rest/system/DatabaseResource.java | 101 +++++++
.../rest/system/QueueSystemResource.java | 77 +++++
.../apache/usergrid/rest/SystemResourceIT.java | 24 +-
.../collection/groups/GroupResourceIT.java | 6 +-
.../test/resource/endpoints/NamedResource.java | 163 ++++++-----
.../test/resource/endpoints/RootResource.java | 5 +
.../test/resource/endpoints/SubResource.java | 37 +++
.../test/resource/endpoints/SystemResource.java | 7 +-
.../test/resource/endpoints/UrlResource.java | 8 +
.../services/notifications/gcm/GCMAdapter.java | 7 +-
.../usergrid/services/roles/RolesService.java | 12 -
42 files changed, 956 insertions(+), 922 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
index 3497621,fd85d94..1514e48
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
@@@ -24,12 -30,11 +30,15 @@@ import org.slf4j.LoggerFactory
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
+ import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+
+
@Path( "/system" )
@Component
@Scope( "singleton" )
@@@ -49,12 -54,9 +58,11 @@@ public class SystemResource extends Abs
@RequireSystemAccess
@GET
+
@Path( "superuser/setup" )
- @JSONP
- public JSONWithPadding getSetupSuperuser( @Context UriInfo ui,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+ @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
+ public ApiResponse getSetupSuperuser( @Context UriInfo ui,
+ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
throws Exception {
ApiResponse response = createApiResponse();
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/main/java/org/apache/usergrid/rest/system/ApplicationsResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/system/ApplicationsResource.java
index 0000000,724a8cf..82bc4c8
mode 000000,100644..100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/system/ApplicationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/system/ApplicationsResource.java
@@@ -1,0 -1,168 +1,168 @@@
+ /*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+ package org.apache.usergrid.rest.system;
+
-import com.sun.jersey.api.json.JSONWithPadding;
++import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+ import org.apache.usergrid.corepersistence.service.StatusService;
+ import org.apache.usergrid.persistence.EntityManager;
+ import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+ import org.apache.usergrid.rest.AbstractContextResource;
+ import org.apache.usergrid.rest.ApiResponse;
+ import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ import org.springframework.context.annotation.Scope;
+ import org.springframework.stereotype.Component;
+
+ import javax.ws.rs.*;
+ import javax.ws.rs.core.Context;
+ import javax.ws.rs.core.MediaType;
+ import javax.ws.rs.core.UriInfo;
+ import java.util.HashMap;
+ import java.util.LinkedHashMap;
+ import java.util.Map;
+ import java.util.UUID;
+ import java.util.concurrent.atomic.AtomicInteger;
+
+ /**
+ * Classy class class.
+ */
+ @Component
+ @Scope( "singleton" )
+ @Produces( {
+ MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+ "application/ecmascript", "text/jscript"
+ } )
+ public class ApplicationsResource extends AbstractContextResource {
+
+ private static final Logger logger = LoggerFactory.getLogger(ApplicationsResource.class);
+
+
+ public ApplicationsResource() {
-
+ logger.info( "ApplicationsResource initialized" );
- } {
-
+ }
+
+ @RequireSystemAccess
+ @DELETE
++ @JSONP
+ @Path( "{applicationId}" )
- public JSONWithPadding clearApplication( @Context UriInfo ui,
- @PathParam("applicationId") UUID applicationId,
- @QueryParam( "confirmApplicationName" ) String confirmApplicationName,
- @QueryParam( "limit" ) int limit,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++ public ApiResponse clearApplication(
++ @Context UriInfo ui,
++ @PathParam("applicationId") UUID applicationId,
++ @QueryParam( "confirmApplicationName" ) String confirmApplicationName,
++ @QueryParam( "limit" ) int limit,
++ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++
+ throws Exception {
+
+ if(confirmApplicationName == null){
+ throw new IllegalArgumentException("please make add a QueryString for confirmApplicationName");
+ }
+
+ final UUID jobId = UUIDGenerator.newTimeUUID();
+
+ final EntityManager em = emf.getEntityManager(applicationId);
+ final String name = em.getApplication().getApplicationName();
+ if(!name.toLowerCase().equals(confirmApplicationName.toLowerCase())){
- throw new IllegalArgumentException("confirmApplicationName: " + confirmApplicationName + " does not equal " + name);
++ throw new IllegalArgumentException(
++ "confirmApplicationName: " + confirmApplicationName + " does not equal " + name);
+ }
+ final StatusService statusService = injector.getInstance(StatusService.class);
+
+ final ApiResponse response = createApiResponse();
+
+ response.setAction( "clear application" );
+
+ logger.info("clearing up application");
+
-
+ final Thread delete = new Thread() {
+
+ @Override
+ public void run() {
+ final AtomicInteger itemsDeleted = new AtomicInteger(0);
+ try {
+ management.deleteAllEntities(applicationId, limit)
+ .map(id -> itemsDeleted.incrementAndGet())
+ .doOnNext(count -> {
+ if( count % 100 == 0 ){
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("count",itemsDeleted.intValue());
+ final StatusService statusService = injector.getInstance(StatusService.class);
+ statusService.setStatus(applicationId, jobId, StatusService.Status.INPROGRESS,map).subscribe();
+ }
+ })
+ .doOnCompleted(() ->{
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("count",itemsDeleted.intValue());
+ final StatusService statusService = injector.getInstance(StatusService.class);
+ statusService.setStatus(applicationId,jobId, StatusService.Status.COMPLETE,map).subscribe();
+ })
+ .subscribe();
+
+ } catch ( Exception e ) {
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("exception",e);
+ statusService.setStatus(applicationId,jobId, StatusService.Status.FAILED,map).subscribe();
+ logger.error( "Failed to delete appid:"+applicationId + " jobid:"+jobId+" count:"+itemsDeleted, e );
+ }
+ }
+ };
+
+ delete.setName("Delete for app : " + applicationId + " job: " + jobId);
+ delete.setDaemon(true);
+ delete.start();
+
+ statusService.setStatus(applicationId,jobId, StatusService.Status.STARTED,new LinkedHashMap<>()).subscribe();
+
+ Map<String,Object> data = new HashMap<>();
+ data.put("jobId",jobId);
+ data.put("status",StatusService.Status.STARTED);
+ response.setData(data);
+ response.setSuccess();
- return new JSONWithPadding( response, callback );
++ return response;
+ }
+
+ @RequireSystemAccess
+ @GET
+ @Path( "{applicationId}/job/{jobId}" )
- public JSONWithPadding getStatus( @Context UriInfo ui,
- @PathParam("applicationId") UUID applicationId,
- @PathParam("jobId") UUID jobId,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception{
++ public ApiResponse getStatus(
++ @Context UriInfo ui,
++ @PathParam("applicationId") UUID applicationId,
++ @PathParam("jobId") UUID jobId,
++ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception{
++
+ final StatusService statusService = injector.getInstance(StatusService.class);
+
+ final ApiResponse response = createApiResponse();
+
+ response.setAction( "clear application" );
+
+ StatusService.JobStatus jobStatus = statusService.getStatus(applicationId, jobId).toBlocking().lastOrDefault(null);
+
+ Map<String,Object> data = new HashMap<>();
+ data.put("jobId",jobId);
+ data.put( "status", jobStatus.getStatus().toString() );
+ data.put( "metadata", jobStatus.getData() );
+ response.setData(data);
+ response.setSuccess();
-
- return new JSONWithPadding( response, callback );
-
++ return response;
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/main/java/org/apache/usergrid/rest/system/DatabaseResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/system/DatabaseResource.java
index 0000000,f24bfc8..b261c96
mode 000000,100644..100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/system/DatabaseResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/system/DatabaseResource.java
@@@ -1,0 -1,100 +1,101 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.rest.system;
+
+
+ import javax.ws.rs.DefaultValue;
+ import javax.ws.rs.PUT;
+ import javax.ws.rs.Path;
+ import javax.ws.rs.Produces;
+ import javax.ws.rs.QueryParam;
+ import javax.ws.rs.core.Context;
+ import javax.ws.rs.core.MediaType;
+ import javax.ws.rs.core.UriInfo;
+
+ import org.apache.usergrid.rest.AbstractContextResource;
+ import org.apache.usergrid.rest.ApiResponse;
++import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ import org.springframework.context.annotation.Scope;
+ import org.springframework.stereotype.Component;
+
+ import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+
-import com.sun.jersey.api.json.JSONWithPadding;
-
+
+ @Component
+ @Scope( "singleton" )
+ @Produces( {
+ MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+ "application/ecmascript", "text/jscript"
+ } )
+ public class DatabaseResource extends AbstractContextResource {
+
+ private static final Logger logger = LoggerFactory.getLogger( DatabaseResource.class );
+
+
+ public DatabaseResource() {
+ logger.info( "DatabaseResource initialized" );
+ }
+
+
+ @RequireSystemAccess
+ @PUT
++ @JSONP
+ @Path( "setup" )
- public JSONWithPadding runDatabaseSetup( @Context UriInfo ui,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++ public ApiResponse runDatabaseSetup( @Context UriInfo ui,
++ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+ throws Exception {
+
+ ApiResponse response = createApiResponse();
+ response.setAction( "cassandra setup" );
+
+ logger.info( "Setting up Cassandra" );
+
+
+ emf.setup();
+
+
+ response.setSuccess();
+
- return new JSONWithPadding( response, callback );
++ return response;
+ }
+
+
+ @RequireSystemAccess
+ @PUT
++ @JSONP
+ @Path( "bootstrap" )
- public JSONWithPadding runSystemSetup( @Context UriInfo ui,
- @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++ public ApiResponse runSystemSetup( @Context UriInfo ui,
++ @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+ throws Exception {
+
+ ApiResponse response = createApiResponse();
+ response.setAction( "cassandra setup" );
+
+ logger.info( "Setting up Cassandra" );
+
+
+ emf.boostrap();
+ management.setup();
+
+ response.setSuccess();
+
- return new JSONWithPadding( response, callback );
++ return response;
+ }
+ }
+
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/main/java/org/apache/usergrid/rest/system/QueueSystemResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/system/QueueSystemResource.java
index 0000000,0721d89..15bdb34
mode 000000,100644..100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/system/QueueSystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/system/QueueSystemResource.java
@@@ -1,0 -1,78 +1,77 @@@
+ /*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. The ASF licenses this file to You
+ * * under the Apache License, Version 2.0 (the "License"); you may not
+ * * use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+ package org.apache.usergrid.rest.system;
+
+ import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+ import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.sun.jersey.api.json.JSONWithPadding;
+ import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
+ import org.apache.usergrid.rest.AbstractContextResource;
+ import org.apache.usergrid.rest.ApiResponse;
+ import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ import org.springframework.context.annotation.Scope;
+ import org.springframework.stereotype.Component;
+
+ import javax.ws.rs.*;
+ import javax.ws.rs.core.MediaType;
+
+ /**
+ * retrieves queue stats
+ */
+ @Component
+ @Scope( "singleton" )
+ @Produces( {
+ MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+ "application/ecmascript", "text/jscript"
+ } )
+ public class QueueSystemResource extends AbstractContextResource {
+ private static final Logger logger = LoggerFactory.getLogger(QueueSystemResource.class);
+
+ public QueueSystemResource(){logger.info("queue resource initialized");}
+
+ /**
+ * Return queue depth of this Usergrid instance in JSON format.
+ *
+ * By Default this end-point will ignore errors but if you call it with ignore_status=false
+ * then it will return HTTP 500 if either the Entity store or the Index for the management
+ * application are in a bad state.
+ *
+ */
+ @GET
+ @RequireSystemAccess
+ @Path("size")
- public JSONWithPadding getQueueDepth(
++ public ApiResponse getQueueDepth(
+ @QueryParam("callback") @DefaultValue("callback") String callback ) {
+
+ ApiResponse response = createApiResponse();
+ response.setAction( "get queue depth" );
+
+ AsyncEventService eventService = injector.getInstance(AsyncEventService.class);
+ ObjectNode node = JsonNodeFactory.instance.objectNode();
+
+ node.put("queueDepth", eventService.getQueueDepth());
+
+ response.setProperty( "data", node );
+
- return new JSONWithPadding( response, callback );
++ return response;
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
index ae9a2c2,44fa036..dd2a733
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
@@@ -20,9 -20,11 +20,10 @@@ package org.apache.usergrid.rest
import org.apache.usergrid.rest.test.resource.AbstractRestIT;
import org.apache.usergrid.rest.test.resource.model.Entity;
import org.apache.usergrid.rest.test.resource.model.QueryParameters;
+import org.junit.Test;
import java.util.LinkedHashMap;
+ import java.util.Map;
import java.util.UUID;
import static org.junit.Assert.assertEquals;
@@@ -61,8 -64,7 +62,7 @@@ public class SystemResourceIT extends A
queryParameters.addParam( "access_token", clientSetup.getSuperuserToken().getAccessToken() );
queryParameters.addParam("confirmApplicationName", this.clientSetup.getAppName());
- org.apache.usergrid.rest.test.resource.model.ApiResponse result =
- clientSetup.getRestClient().system().applications(this.clientSetup.getAppUuid()).delete( queryParameters);
- org.apache.usergrid.rest.test.resource.model.ApiResponse result = clientSetup.getRestClient().system().getSubResource("applications/" + this.clientSetup.getAppUuid()).delete(false, true, queryParameters);
++ org.apache.usergrid.rest.test.resource.model.ApiResponse result = clientSetup.getRestClient().system().getSubResource("applications/" + this.clientSetup.getAppUuid()).delete(false, queryParameters);
assertNotNull(result);
assertNotNull("ok", result.getStatus());
@@@ -97,6 -99,18 +97,18 @@@
result = clientSetup.getRestClient().system().database().bootstrap().put( queryParameters );
assertNotNull( result );
- assertNotNull( "ok", ( String ) result.get( "status" ) );
+ assertNotNull("ok", (String) result.get("status"));
+ }
+ @Test
+ public void testQueueDepth() {
+ QueryParameters queryParameters = new QueryParameters();
+ queryParameters.addParam("access_token", clientSetup.getSuperuserToken().getAccessToken());
+
- Entity result = clientSetup.getRestClient().system().getSubResource("queue/size").get(Entity.class, queryParameters,false,true);
++ Entity result = clientSetup.getRestClient().system().getSubResource("queue/size").get(Entity.class, queryParameters,false);
+
+ assertNotNull( result );
+ assertEquals(0, ((Map) result.get("data")).get("queueDepth"));
+
+
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index 0db7601,a1bd03c..abf2be5
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@@ -296,11 -302,11 +298,11 @@@ public class GroupResourceIT extends Ab
//9. do a GET to make sure the role was deleted
try {
- this.app().collection("role").entity(role).get();
+ Entity entity1 = this.app().collection("role").entity(role).get();
fail("Entity still exists");
- } catch (UniformInterfaceException e) {
+ } catch (ClientErrorException e) {
//verify the correct error was returned
- JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
assertEquals( "entity_not_found", node.get( "error" ).textValue() );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
index c8979f0,79ecb9e..0254d18
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
@@@ -17,6 -17,11 +17,7 @@@
package org.apache.usergrid.rest.test.resource.endpoints;
-import com.sun.jersey.api.client.GenericType;
-import com.sun.jersey.api.client.WebResource;
+ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
-import com.sun.jersey.api.representation.Form;
-import com.sun.jersey.multipart.FormDataMultiPart;
import org.apache.usergrid.rest.test.resource.model.ApiResponse;
import org.apache.usergrid.rest.test.resource.model.Entity;
import org.apache.usergrid.rest.test.resource.model.QueryParameters;
@@@ -44,16 -41,17 +45,18 @@@ import java.util.Set
*/
public class NamedResource implements UrlResource {
-- public static String SLASH ="/" ;
++ public static String SLASH = "/";
protected final String name;
protected final ClientContext context;
- /* Stores the path of the parent that called it.
- i.e If we had a ApplicationResource ( an instance of a namedResource ) this would contain the OrganizationResource.
+
- /** Stores the path of the parent that called it. i.e If we had a ApplicationResource
- (an instance of a namedResource) this would contain the OrganizationResource. */
++ /**
++ * Stores the path of the parent that called it. i.e If we had a ApplicationResource
++ * (an instance of a namedResource) this would contain the OrganizationResource.
+ */
protected final UrlResource parent;
-
-- public NamedResource( final String name, final ClientContext context, final UrlResource parent ) {
++ public NamedResource(final String name, final ClientContext context, final UrlResource parent) {
this.name = name;
this.context = context;
this.parent = parent;
@@@ -65,59 -64,57 +68,64 @@@
}
@Override
- public WebResource getResource() {
- return getResource(false);
+ public WebTarget getTarget() {
- return getTarget( false );
++ return getTarget(false);
++ }
++
++ @Override
++ public ClientContext getContext() {
++ return context;
}
- public WebResource getResource(boolean useToken) {
- return getResource(useToken,null);
+
+ public WebTarget getTarget(boolean useToken) {
- return getTarget( useToken, null );
++ return getTarget(useToken, null);
}
- public WebResource getResource(boolean useToken,Token token) {
- WebResource resource = parent.getResource().path( getPath() );
- token = token !=null ? token : this.context.getToken();
+
+ public WebTarget getTarget(boolean useToken, Token token) {
- WebTarget resource = parent.getTarget().path( getPath() );
- token = token !=null ? token : this.context.getToken();
++ WebTarget resource = parent.getTarget().path(getPath());
++ token = token != null ? token : this.context.getToken();
//error checking
if (token == null) {
return resource;
}
- return useToken ? resource.queryParam("access_token", token.getAccessToken()) : resource;
- return useToken ? resource.queryParam("access_token",token.getAccessToken()) : resource;
++ return useToken ? resource.queryParam("access_token", token.getAccessToken()) : resource;
}
- protected WebTarget addParametersToResource(WebTarget resource, final QueryParameters parameters){
- protected WebResource addParametersToResource(WebResource resource, final QueryParameters parameters){
++ protected WebTarget addParametersToResource(WebTarget resource, final QueryParameters parameters) {
-- if(parameters == null){
++ if (parameters == null) {
return resource;
}
-- if ( parameters.getQuery() != null ) {
-- resource = resource.queryParam( "ql", parameters.getQuery() );
++ if (parameters.getQuery() != null) {
++ resource = resource.queryParam("ql", parameters.getQuery());
}
-- if ( parameters.getCursor() != null ) {
-- resource = resource.queryParam( "cursor", parameters.getCursor() );
++ if (parameters.getCursor() != null) {
++ resource = resource.queryParam("cursor", parameters.getCursor());
}
-- if ( parameters.getStart() != null ) {
++ if (parameters.getStart() != null) {
resource = resource.queryParam("start", parameters.getStart().toString());
}
-- if ( parameters.getLimit() != null ) {
++ if (parameters.getLimit() != null) {
resource = resource.queryParam("limit", parameters.getLimit().toString());
}
-- if ( parameters.getConnections() != null ) {
++ if (parameters.getConnections() != null) {
resource = resource.queryParam("connections", parameters.getConnections());
}
//We can also post the params as queries
-- if ( parameters.getFormPostData().size() > 0){
-- Map<String,String> formData = parameters.getFormPostData();
++ if (parameters.getFormPostData().size() > 0) {
++ Map<String, String> formData = parameters.getFormPostData();
Set<String> keySet = formData.keySet();
Iterator<String> keyIterator = keySet.iterator();
-- while(keyIterator.hasNext()){
++ while (keyIterator.hasNext()) {
String key = keyIterator.next();
-- String value = formData.get( key );
-- resource = resource.queryParam( key, value );
++ String value = formData.get(key);
++ resource = resource.queryParam(key, value);
}
}
return resource;
@@@ -167,6 -164,6 +175,7 @@@
/**
* Need to refactor all instances of tokens to either be passed in or manually set during the test.
* There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
++ *
* @param map
* @return
*/
@@@ -178,89 -175,112 +187,89 @@@
//For edge cases like Organizations and Tokens
public ApiResponse post(boolean useToken, Map map, QueryParameters queryParameters) {
-- return post( useToken, ApiResponse.class, map, queryParameters, false );
++ return post(useToken, ApiResponse.class, map, queryParameters, false);
}
/**
* Need to refactor all instances of tokens to either be passed in or manually set during the test.
* There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
- * @param type
- * @param <T>
- * @return
+ * For edge cases like Organizations and Tokens
*/
- //For edge cases like Organizations and Tokens
public <T> T post(Class<T> type) {
-- return post(true,type,null,null,false);
++ return post(true, type, null, null, false);
}
/**
* Need to refactor all instances of tokens to either be passed in or manually set during the test.
* There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
- * @param type
- * @param requestEntity
- * @param <T>
- * @return
+ * For edge cases like Organizations and Tokens.
*/
- //For edge cases like Organizations and Tokens
public <T> T post(Class<T> type, Entity requestEntity) {
- return post( true, type, requestEntity, null, false);
- return post(true,type,requestEntity,null,false);
++ return post(true, type, requestEntity, null, false);
}
/**
* Need to refactor all instances of tokens to either be passed in or manually set during the test.
* There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
- * @param type
- * @param requestEntity
- * @param <T>
- * @return
+ * For edge cases like Organizations and Tokens
*/
- //For edge cases like Organizations and Tokens
public <T> T post(Class<T> type, Map requestEntity) {
-- return post(true,type,requestEntity,null,false);
++ return post(true, type, requestEntity, null, false);
}
-- public <T> T post( boolean useToken, Class<T> type, Map requestEntity) {
++ public <T> T post(boolean useToken, Class<T> type, Map requestEntity) {
return post(useToken, type, requestEntity, null, false);
}
/**
* Used to test POST using form payloads.
- * @param type
- * @param requestEntity
- * @param <T>
- * @return
*/
- public <T> T post(Class<T> type, Form requestEntity) {
+ public <T> T post(Class<T> type, Form form) {
GenericType<T> gt = new GenericType<>((Class) type);
- return getResource()
+ return getTarget().request()
- .accept( MediaType.APPLICATION_JSON )
- .post( javax.ws.rs.client.Entity.entity( form, MediaType.APPLICATION_FORM_URLENCODED_TYPE ), gt );
+ .accept(MediaType.APPLICATION_JSON)
- .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
- .entity(requestEntity, MediaType.APPLICATION_FORM_URLENCODED_TYPE)
- .post(gt.getRawClass());
-
++ .post(javax.ws.rs.client.Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), gt);
}
- //Used for empty posts
- public <T> T post( boolean useToken, Class<T> type, Map entity, final QueryParameters queryParameters) {
- WebResource resource = getResource(useToken);
+ // Used for empty posts
- public <T> T post( boolean useToken, Class<T> type, Map entity, final QueryParameters queryParameters) {
- WebTarget resource = getTarget( useToken );
- resource = addParametersToResource( resource, queryParameters );
++ public <T> T post(boolean useToken, Class<T> type, Map entity, final QueryParameters queryParameters) {
++ WebTarget resource = getTarget(useToken);
+ resource = addParametersToResource(resource, queryParameters);
- WebResource.Builder builder = resource
- .type(MediaType.APPLICATION_JSON_TYPE)
- .accept( MediaType.APPLICATION_JSON );
- if(entity!=null){
- builder.entity(entity);
- }
- GenericType<T> gt = new GenericType<>((Class) type);
- return builder
- .post(gt.getRawClass());
+ Invocation.Builder builder = resource.request()
- .accept( MediaType.APPLICATION_JSON );
++ .accept(MediaType.APPLICATION_JSON);
+ // it's OK for the entity to be null
+ GenericType<T> gt = new GenericType<>((Class) type);
- return builder.post( javax.ws.rs.client.Entity.json( entity ), gt );
++ return builder.post(javax.ws.rs.client.Entity.json(entity), gt);
}
- //Used for empty posts
- public <T> T post( boolean useToken, Class<T> type, Map entity, final QueryParameters queryParameters, boolean useBasicAuthentication ) {
- WebResource resource = getResource(useToken);
+ // Used for empty posts
- public <T> T post( boolean useToken, Class<T> type, Map entity,
- final QueryParameters queryParameters, boolean useBasicAuthentication ) {
++ public <T> T post(boolean useToken, Class<T> type, Map entity,
++ final QueryParameters queryParameters, boolean useBasicAuthentication) {
+
- WebTarget resource = getTarget( useToken );
++ WebTarget resource = getTarget(useToken);
resource = addParametersToResource(resource, queryParameters);
- WebResource.Builder builder = resource
- .type(MediaType.APPLICATION_JSON_TYPE)
- .accept( MediaType.APPLICATION_JSON );
- if(entity!=null){
- builder.entity(entity);
- }
+ GenericType<T> gt = new GenericType<>((Class) type);
- if ( useBasicAuthentication ) {
- if(useBasicAuthentication){
- //added httpBasicauth filter to all setup calls because they all do verification this way.
- HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
- resource.addFilter(httpBasicAuthFilter);
++ if (useBasicAuthentication) {
+ HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
- .credentials( "superuser", "superpassword" ).build();
- return resource.register( feature ).request()
- .accept( MediaType.APPLICATION_JSON )
- .post( javax.ws.rs.client.Entity.json( entity ), gt );
++ .credentials("superuser", "superpassword").build();
++ return resource.register(feature).request()
++ .accept(MediaType.APPLICATION_JSON)
++ .post(javax.ws.rs.client.Entity.json(entity), gt);
}
- GenericType<T> gt = new GenericType<>((Class) type);
- return builder.post(gt.getRawClass());
-
+ return resource.request()
- .accept( MediaType.APPLICATION_JSON )
- .post( javax.ws.rs.client.Entity.json( entity ), gt );
++ .accept(MediaType.APPLICATION_JSON)
++ .post(javax.ws.rs.client.Entity.json(entity), gt);
}
//For edge cases like Organizations and Tokens without any payload
@@@ -271,82 -291,104 +280,88 @@@
//For edge cases like Organizations and Tokens without any payload
public <T> T get(Class<T> type, boolean useToken) {
-- return get( type, null, useToken );
++ return get(type, null, useToken);
}
--
-- public <T> T get(Class<T> type,QueryParameters queryParameters) {
- return get( type, queryParameters, true );
++ public <T> T get(Class<T> type, QueryParameters queryParameters) {
+ return get(type, queryParameters, true);
}
- public <T> T get(Class<T> type,QueryParameters queryParameters, boolean useToken) {
- return get(type,queryParameters,useToken,false);
- }
- public <T> T get(Class<T> type,QueryParameters queryParameters, boolean useToken, boolean useSupertoken) {
- WebResource resource = getResource(useToken);
- if(queryParameters!=null) {
+
+ public <T> T get(Class<T> type, QueryParameters queryParameters, boolean useToken) {
- WebTarget resource = getTarget( useToken );
++
++ WebTarget resource = getTarget(useToken);
+ if (queryParameters != null) {
resource = addParametersToResource(resource, queryParameters);
}
- if(useSupertoken) {
- //added httpBasicauth filter to all setup calls because they all do verification this way.
- HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter("superuser", "superpassword");
- resource.addFilter(httpBasicAuthFilter);
- }
- GenericType<T> gt = new GenericType<>((Class) type);
- return resource.type(MediaType.APPLICATION_JSON_TYPE)
- .accept( MediaType.APPLICATION_JSON )
- .get(gt.getRawClass());
+
+ GenericType<T> gt = new GenericType<>((Class) type);
+ return resource.request()
- .accept( MediaType.APPLICATION_JSON )
- .get( gt );
++ .accept(MediaType.APPLICATION_JSON)
++ .get(gt);
}
public String getMatrix() {
return "";
}
- public ApiResponse post( boolean useToken, MultiPart multiPartForm ) {
- WebTarget resource = getTarget( useToken );
- public ApiResponse post( boolean useToken, FormDataMultiPart multiPartForm ) {
- WebResource resource = getResource( useToken );
- return resource.type( MediaType.MULTIPART_FORM_DATA_TYPE ).post(ApiResponse.class, multiPartForm);
++ public ApiResponse post(boolean useToken, MultiPart multiPartForm) {
++ WebTarget resource = getTarget(useToken);
+ return resource.request().post(
- javax.ws.rs.client.Entity.entity( multiPartForm, multiPartForm.getMediaType() ), ApiResponse.class );
++ javax.ws.rs.client.Entity.entity(multiPartForm, multiPartForm.getMediaType()), ApiResponse.class);
}
- public ApiResponse post( MultiPart multiPartForm ) {
- return post( true, multiPartForm );
- public ApiResponse post( FormDataMultiPart multiPartForm ) {
++ public ApiResponse post(MultiPart multiPartForm) {
+ return post(true, multiPartForm);
}
-- public ApiResponse put( boolean useToken, byte[] data, MediaType type ) {
- WebTarget resource = getTarget( useToken );
- WebResource resource = getResource(useToken);
- return resource.type( type ).put(ApiResponse.class, data);
++ public ApiResponse put(boolean useToken, byte[] data, MediaType type) {
++ WebTarget resource = getTarget(useToken);
+ return resource.request().put(
- javax.ws.rs.client.Entity.entity(data, type), ApiResponse.class );
++ javax.ws.rs.client.Entity.entity(data, type), ApiResponse.class);
}
-- public ApiResponse put( byte[] data, MediaType type ) {
++ public ApiResponse put(byte[] data, MediaType type) {
return put(true, data, type);
}
-- public ApiResponse put( boolean useToken, FormDataMultiPart multiPartForm ) {
- WebTarget resource = getTarget(useToken );
- WebResource resource = getResource(useToken);
- return resource.type( MediaType.MULTIPART_FORM_DATA_TYPE ).put(ApiResponse.class, multiPartForm);
++ public ApiResponse put(boolean useToken, FormDataMultiPart multiPartForm) {
++ WebTarget resource = getTarget(useToken);
+ return resource.request().put(
- javax.ws.rs.client.Entity.entity(multiPartForm, multiPartForm.getMediaType()), ApiResponse.class );
++ javax.ws.rs.client.Entity.entity(multiPartForm, multiPartForm.getMediaType()), ApiResponse.class);
}
-- public ApiResponse put( FormDataMultiPart multiPartForm ) {
++ public ApiResponse put(FormDataMultiPart multiPartForm) {
return put(true, multiPartForm);
}
-- public InputStream getAssetAsStream( boolean useToken ) {
- WebTarget resource = getTarget(useToken );
- return resource.request().accept( MediaType.APPLICATION_OCTET_STREAM_TYPE ).get( InputStream.class );
- WebResource resource = getResource(useToken);
- return resource.accept( MediaType.APPLICATION_OCTET_STREAM_TYPE ).get(InputStream.class);
++ public InputStream getAssetAsStream(boolean useToken) {
++ WebTarget resource = getTarget(useToken);
++ return resource.request().accept(MediaType.APPLICATION_OCTET_STREAM_TYPE).get(InputStream.class);
}
public InputStream getAssetAsStream() {
return getAssetAsStream(true);
}
-- public ApiResponse delete( ) {
++ public ApiResponse delete() {
return delete(true);
}
-- public ApiResponse delete( boolean useToken ) {
- return getTarget(useToken).request().delete( ApiResponse.class );
- return getResource(useToken).delete(ApiResponse.class);
++ public ApiResponse delete(boolean useToken) {
++ return getTarget(useToken).request().delete(ApiResponse.class);
}
- public ApiResponse delete( boolean useToken, QueryParameters queryParameters ) {
- return delete(useToken,false,queryParameters);
- }
- public ApiResponse delete( boolean useToken, boolean useSupertoken, QueryParameters queryParameters ) {
- WebResource resource = getResource(useToken);
- if(queryParameters!=null) {
- resource = addParametersToResource(resource, queryParameters);
- }
- if(useSupertoken) {
- //added httpBasicauth filter to all setup calls because they all do verification this way.
- HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter("superuser", "superpassword");
- resource.addFilter(httpBasicAuthFilter);
- }
- return resource.delete(ApiResponse.class);
- }
-
- public ApiResponse delete( boolean useToken, QueryParameters queryParameters ) {
++ public ApiResponse delete(boolean useToken, QueryParameters queryParameters) {
+ WebTarget resource = getTarget(useToken);
- if(queryParameters!=null) {
+
- public ClientContext getContext(){
- return context;
++ if (queryParameters != null) {
+ resource = addParametersToResource(resource, queryParameters);
+ }
- return resource.request().delete( ApiResponse.class );
++ return resource.request().delete(ApiResponse.class);
+ }
+
- public NamedResource getSubResource(final String path){
- return SubResource.getInstance(path,this);
++ public NamedResource getSubResource(String path) {
++ return new NamedResource(path,context,this);
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
index 96e8fa5,1a7b594..82b0468
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
@@@ -58,33 -58,27 +58,38 @@@ public class SystemResource extends Nam
public ApiResponse get(QueryParameters queryParameters){
- WebResource resource = getResource();
+ WebTarget resource = getTarget();
resource = addParametersToResource( resource, queryParameters );
- //added httpBasicauth filter to all setup calls because they all do verification this way.
- HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
- resource.addFilter(httpBasicAuthFilter);
+ HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+ .credentials( "superuser", "superpassword" ).build();
- return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
+ return resource.register( feature ).request().accept( MediaType.APPLICATION_JSON )
.get(ApiResponse.class);
}
- public ApiResponse delete(QueryParameters queryParameters){
- WebResource resource = getResource();
+
+ public ApiResponse delete(QueryParameters queryParameters) {
+
+ WebTarget resource = getTarget();
resource = addParametersToResource( resource, queryParameters );
- //added httpBasicauth filter to all setup calls because they all do verification this way.
- HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
- resource.addFilter(httpBasicAuthFilter);
+ HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+ .credentials( "superuser", "superpassword" ).build();
+
- return resource.register( feature ).request().delete( ApiResponse.class );
++ return resource.register(feature).request().delete(ApiResponse.class);
+
+ }
+
- return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
- .delete(ApiResponse.class);
++ @Override
++ public ClientContext getContext() {
++ return context;
+ }
}
+
+ public ApiResponse put(){
+ ApiResponse response = getTarget(true).request().accept(MediaType.APPLICATION_JSON)
+ .put( javax.ws.rs.client.Entity.json(""), ApiResponse.class);
+ return response;
+ }
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/684bf2af/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
index 6e5ee1b,b040aee..d16ae70
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
@@@ -17,7 -17,10 +17,9 @@@
package org.apache.usergrid.rest.test.resource.endpoints;
+ import org.apache.usergrid.rest.test.resource.state.ClientContext;
+
-import com.sun.jersey.api.client.WebResource;
-
+import javax.ws.rs.client.WebTarget;
/**
* Interface that returns the path that is currently being pointed to.
@@@ -35,7 -38,13 +37,13 @@@ public interface UrlResource
* Get the resource
* @return
*/
- public WebResource getResource();
+ public WebTarget getTarget();
+ /**
+ * get context
+ * @return
+ */
+ public ClientContext getContext();
+
}
[14/25] usergrid git commit: item is missing from get role by name
Posted by sn...@apache.org.
item is missing from get role by name
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/08f316f5
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/08f316f5
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/08f316f5
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 08f316f5304338b51ff252b7bd199ea988276ed9
Parents: 1ad074f
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 14:42:18 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 14:42:18 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 20 ++++++++++++--------
.../corepersistence/CpRelationManager.java | 6 ++----
.../usergrid/persistence/EntityManager.java | 2 ++
3 files changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/08f316f5/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 976e69f..5dd618e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -1776,24 +1776,28 @@ public class CpEntityManager implements EntityManager {
//TODO: does this need graphite monitoring
@Override
- public void deleteRole( String roleName ) throws Exception {
- roleName = roleName.toLowerCase();
- Set<String> permissions = getRolePermissions( roleName );
+ public void deleteRole(final String roleName ) throws Exception {
+ deleteRole(roleName, Optional.absent());
+ }
+
+ @Override
+ public void deleteRole(final String roleName, final Optional<EntityRef> roleRef ) throws Exception {
+ final String roleNameLowerCase = roleName.toLowerCase();
+ Set<String> permissions = getRolePermissions( roleNameLowerCase );
Iterator<String> itrPermissions = permissions.iterator();
while ( itrPermissions.hasNext() ) {
- revokeRolePermission( roleName, itrPermissions.next() );
+ revokeRolePermission( roleNameLowerCase, itrPermissions.next() );
}
- removeFromDictionary( getApplicationRef(), DICTIONARY_ROLENAMES, roleName );
- removeFromDictionary( getApplicationRef(), DICTIONARY_ROLETIMES, roleName );
- EntityRef entity = getRoleRef( roleName );
+ removeFromDictionary(getApplicationRef(), DICTIONARY_ROLENAMES, roleNameLowerCase);
+ removeFromDictionary(getApplicationRef(), DICTIONARY_ROLETIMES, roleNameLowerCase);
+ final EntityRef entity = roleRef.isPresent() ? roleRef.get() : getRoleRef( roleNameLowerCase );
if ( entity != null ) {
delete( entity );
}
}
-
@Override
public Map<String, String> getGroupRoles( UUID groupId ) throws Exception {
return cast( getDictionaryAsMap( new SimpleEntityRef( Group.ENTITY_TYPE, groupId ), DICTIONARY_ROLENAMES ) );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/08f316f5/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index fbcaade..c0b85e8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -491,11 +491,9 @@ public class CpRelationManager implements RelationManager {
Entity itemEntity = em.get( itemRef );
if ( itemEntity != null ) {
RoleRef roleRef = SimpleRoleRef.forRoleEntity( itemEntity );
- em.deleteRole( roleRef.getApplicationRoleName() );
+ em.deleteRole(roleRef.getApplicationRoleName(), Optional.fromNullable(itemEntity) );
return;
}
- em.delete( itemEntity );
- return;
}
em.delete( itemRef );
return;
@@ -546,7 +544,7 @@ public class CpRelationManager implements RelationManager {
em.get( new SimpleEntityRef( memberEntity.getId().getType(), memberEntity.getId().getUuid() ) );
RoleRef roleRef = SimpleRoleRef.forRoleEntity( itemEntity );
- em.deleteRole( roleRef.getApplicationRoleName() );
+ em.deleteRole( roleRef.getApplicationRoleName(), Optional.fromNullable(itemEntity) );
}
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/08f316f5/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index 17dc497..9c4a929 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -521,6 +521,8 @@ public interface EntityManager {
public Set<String> getRolePermissions( String roleName ) throws Exception;
public void deleteRole( String roleName ) throws Exception;
+ public void deleteRole( String roleName, final Optional<EntityRef> roleRef ) throws Exception;
+
public EntityRef getGroupRoleRef( UUID ownerId, String roleName ) throws Exception;
[20/25] usergrid git commit: fix time_to_live gcm
Posted by sn...@apache.org.
fix time_to_live gcm
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/549be61e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/549be61e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/549be61e
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 549be61e3b53656e09db4139b3f0376d8c2f4fdc
Parents: 48391ac
Author: Shawn Feldman <sf...@apache.org>
Authored: Sat Sep 19 15:01:06 2015 -0400
Committer: Shawn Feldman <sf...@apache.org>
Committed: Sat Sep 19 15:01:06 2015 -0400
----------------------------------------------------------------------
.../usergrid/services/notifications/gcm/GCMAdapter.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/549be61e/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
index bdd7737..ba404e8 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
@@ -74,7 +74,7 @@ public class GCMAdapter implements ProviderAdapter {
long ttlSeconds = notification.getExpireTTLSeconds();
// max ttl for gcm is 4 weeks - https://developers.google.com/cloud-messaging/http-server-ref
ttlSeconds = ttlSeconds <= 2419200 ? ttlSeconds : 2419200;
- map.put(expiresKey, ttlSeconds);
+ map.put(expiresKey, (int)ttlSeconds);//needs to be int
}
Batch batch = getBatch( map);
batch.add(providerId, tracker);
@@ -204,8 +204,13 @@ public class GCMAdapter implements ProviderAdapter {
Sender sender = new Sender(notifier.getApiKey());
Message.Builder builder = new Message.Builder();
builder.setData(payload);
+ if(payload.containsKey("time_to_live")){
+ int ttl = (int)payload.get("time_to_live");
+ builder.timeToLive(ttl);
+ }
Message message = builder.build();
+
MulticastResult multicastResult = sender.send(message, ids, SEND_RETRIES);
LOG.debug("sendNotification result: {}", multicastResult);
[11/25] usergrid git commit: remove delete index directly from cp
Posted by sn...@apache.org.
remove delete index directly from cp
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/ad2b8253
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/ad2b8253
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/ad2b8253
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: ad2b8253bfc7d5cddef0be3cdea2c8ce0b06c71c
Parents: 34e0e63
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 10:24:55 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 10:24:55 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpRelationManager.java | 9 +----
.../asyncevents/EventBuilderImpl.java | 40 +++++++++++---------
.../collection/groups/GroupResourceIT.java | 1 +
3 files changed, 24 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/ad2b8253/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index cef0646..a4fe400 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -520,8 +520,7 @@ public class CpRelationManager implements RelationManager {
//run our delete
gm.loadEdgeVersions(
CpNamingUtils.createEdgeFromCollectionName( cpHeadEntity.getId(), collectionName, memberEntity.getId() ) )
- .flatMap( edge -> gm.markEdge( edge ) ).flatMap( edge -> gm.deleteEdge( edge ) ).toBlocking()
- .lastOrDefault( null );
+ .flatMap( edge -> gm.markEdge( edge ) ).flatMap( edge -> gm.deleteEdge( edge ) ).subscribe();
/**
@@ -529,13 +528,7 @@ public class CpRelationManager implements RelationManager {
*
*/
- final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
-
- // remove item from collection index
- SearchEdge indexScope = createCollectionSearchEdge( cpHeadEntity.getId(), collectionName );
- final EntityIndexBatch batch = ei.createBatch();
- batch.deindex( indexScope, memberEntity );
//TODO: this should not happen here, needs to go to SQS
//indexProducer.put(batch).subscribe();
indexService.queueEntityDelete(applicationScope,memberEntity.getId());
http://git-wip-us.apache.org/repos/asf/usergrid/blob/ad2b8253/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
index 620bea8..8744889 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
@@ -142,25 +142,29 @@ public class EventBuilderImpl implements EventBuilder {
//If there is nothing marked then we shouldn't return any results.
//TODO: evaluate if we want to return null or return empty observable when we don't have any results marked as deleted.
if(mostRecentlyMarked == null) {
- Observable<IndexOperationMessage> messageObservable = indexService.deleteEntityIndexes(applicationScope, entityId, UUIDUtils.MAX_TIME_UUID);
- return new EntityDeleteResults(messageObservable, Observable.<List<MvccLogEntry>>empty());
+ Observable<IndexOperationMessage> messageObservable = indexService.deleteEntityIndexes(applicationScope, entityId, UUIDUtils.newTimeUUID());
+ final Observable<List<MvccLogEntry>> entries =
+ ecm.getVersions( entityId ).buffer( serializationFig.getBufferSize() )
+ .doOnNext( buffer -> ecm.delete( buffer ) ).doOnCompleted(() -> gm.compactNode(entityId));
+ return new EntityDeleteResults(messageObservable, entries);
+ }else {
+ //observable of index operation messages
+ //this method will need the most recent version.
+ //When we go to compact the graph make sure you turn on the debugging mode for the deleted nodes so
+ //we can verify that we mark them. That said that part seems kinda done. as we also delete the mvcc buffers.
+ final Observable<IndexOperationMessage> edgeObservable =
+ indexService.deleteEntityIndexes(applicationScope, entityId, mostRecentlyMarked.getVersion());
+
+
+ //TODO: not sure what we need the list of versions here when we search for the mark above
+ //observable of entries as the batches are deleted
+ final Observable<List<MvccLogEntry>> entries =
+ ecm.getVersions(entityId).buffer(serializationFig.getBufferSize())
+ .doOnNext(buffer -> ecm.delete(buffer)).doOnCompleted(() -> gm.compactNode(entityId));
+
+
+ return new EntityDeleteResults(edgeObservable, entries);
}
- //observable of index operation messages
- //this method will need the most recent version.
- //When we go to compact the graph make sure you turn on the debugging mode for the deleted nodes so
- //we can verify that we mark them. That said that part seems kinda done. as we also delete the mvcc buffers.
- final Observable<IndexOperationMessage> edgeObservable =
- indexService.deleteEntityIndexes( applicationScope, entityId, mostRecentlyMarked.getVersion() );
-
-
- //TODO: not sure what we need the list of versions here when we search for the mark above
- //observable of entries as the batches are deleted
- final Observable<List<MvccLogEntry>> entries =
- ecm.getVersions( entityId ).buffer( serializationFig.getBufferSize() )
- .doOnNext( buffer -> ecm.delete( buffer ) ).doOnCompleted( () -> gm.compactNode( entityId ) );
-
-
- return new EntityDeleteResults( edgeObservable, entries );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/ad2b8253/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index a52792a..bcf0962 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -297,6 +297,7 @@ public class GroupResourceIT extends AbstractRestIT {
//8. delete the role
this.app().collection("role").entity(role).delete();
+ this.refreshIndex();
//9. do a GET to make sure the role was deleted
try {
[15/25] usergrid git commit: item is missing from get role by name
Posted by sn...@apache.org.
item is missing from get role by name
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/847c39fb
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/847c39fb
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/847c39fb
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 847c39fbe0a3a310dffb554b881c37a8698f9759
Parents: 08f316f
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 14:44:11 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 14:44:11 2015 -0600
----------------------------------------------------------------------
.../org/apache/usergrid/persistence/PermissionsIT.java | 7 ++++---
.../apache/usergrid/services/roles/RolesService.java | 12 ------------
2 files changed, 4 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/847c39fb/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
index a01692a..11f0692 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import com.google.common.base.Optional;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -110,14 +111,14 @@ public class PermissionsIT extends AbstractCoreIT {
assertNotNull( em );
// em.createRole("admin", null);
- em.createRole( "manager", null, 0 );
- em.createRole( "member", null, 100000 );
+ em.createRole("manager", null, 0);
+ Entity memberRole = em.createRole( "member", null, 100000 );
Map<String, String> roles = em.getRoles();
assertEquals( "proper number of roles not set", 5, roles.size() );
dump( "roles", roles );
- em.deleteRole( "member" );
+ em.deleteRole("member", Optional.fromNullable(memberRole));
roles = em.getRoles();
assertEquals( "proper number of roles not set", 4, roles.size() );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/847c39fb/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java b/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
index 475d38d..344ea1f 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/roles/RolesService.java
@@ -196,18 +196,6 @@ public class RolesService extends AbstractCollectionService {
}
- public ServiceResults newApplicationRole( String roleName, String roleTitle, long inactivity ) throws Exception {
- em.createRole( roleName, roleTitle, inactivity );
- return getApplicationRoles();
- }
-
-
- public ServiceResults deleteApplicationRole( String roleName ) throws Exception {
- em.deleteRole( roleName );
- return getApplicationRolePermissions( roleName );
- }
-
-
public ServiceResults getApplicationRolePermissions( String roleName ) throws Exception {
Set<String> permissions = em.getRolePermissions( roleName );
ServiceResults results = genericServiceResults().withData( permissions );
[07/25] usergrid git commit: Merge branch 'USERGRID-1016' into
USERGRID-1022
Posted by sn...@apache.org.
Merge branch 'USERGRID-1016' into USERGRID-1022
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/c05d9731
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c05d9731
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c05d9731
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: c05d9731cc50e62c83a605a71f4eb0ab00fac001
Parents: 7450c94 a562079
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 07:54:30 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 07:54:30 2015 -0600
----------------------------------------------------------------------
.../index/impl/EntityMappingParser.java | 2 +-
.../persistence/index/impl/EsQueryVistor.java | 50 +++++++++-----------
.../persistence/index/impl/EntityIndexTest.java | 13 ++++-
.../index/impl/EntityToMapConverterTest.java | 2 +-
4 files changed, 37 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
[10/25] usergrid git commit: remove index producer dependencies,
and add async deletes
Posted by sn...@apache.org.
remove index producer dependencies, and add async deletes
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/34e0e632
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/34e0e632
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/34e0e632
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 34e0e632506e522be51ee53153aaf0daea525826
Parents: ba829c8
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 08:59:17 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 08:59:17 2015 -0600
----------------------------------------------------------------------
.../org/apache/usergrid/corepersistence/CpEntityManager.java | 6 +-----
.../usergrid/corepersistence/CpEntityManagerFactory.java | 5 +----
.../apache/usergrid/corepersistence/CpRelationManager.java | 8 +++-----
.../corepersistence/asyncevents/EventBuilderImpl.java | 8 +++++---
4 files changed, 10 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/34e0e632/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index e222f68..976e69f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -41,7 +41,6 @@ import org.apache.usergrid.corepersistence.service.ConnectionService;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.IndexLocationStrategy;
import org.apache.usergrid.persistence.index.IndexRefreshCommand;
-import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
@@ -184,7 +183,6 @@ public class CpEntityManager implements EntityManager {
private final UUID applicationId;
private final EntityManagerFig entityManagerFig;
- private final IndexProducer indexProducer;
private Application application;
@@ -248,11 +246,9 @@ public class CpEntityManager implements EntityManager {
final GraphManagerFactory graphManagerFactory,
final CollectionService collectionService,
final ConnectionService connectionService,
- final IndexProducer indexProducer,
final UUID applicationId ) {
this.entityManagerFig = entityManagerFig;
- this.indexProducer = indexProducer;
Preconditions.checkNotNull( cass, "cass must not be null" );
Preconditions.checkNotNull( counterUtils, "counterUtils must not be null" );
@@ -763,7 +759,7 @@ public class CpEntityManager implements EntityManager {
Preconditions.checkNotNull(entityRef, "entityRef cannot be null");
CpRelationManager relationManager =
- new CpRelationManager(managerCache, indexService, collectionService, connectionService, indexProducer, this, entityManagerFig, applicationId, entityRef );
+ new CpRelationManager(managerCache, indexService, collectionService, connectionService, this, entityManagerFig, applicationId, entityRef );
return relationManager;
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/34e0e632/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 4a712a7..4bdade5 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -22,7 +22,6 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
-import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
@@ -97,7 +96,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
private static final Logger logger = LoggerFactory.getLogger( CpEntityManagerFactory.class );
private final EntityManagerFig entityManagerFig;
- private final IndexProducer indexProducer;
private ApplicationContext applicationContext;
@@ -139,7 +137,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
this.graphManagerFactory = injector.getInstance( GraphManagerFactory.class );
this.collectionService = injector.getInstance( CollectionService.class );
this.connectionService = injector.getInstance( ConnectionService.class );
- this.indexProducer = injector.getInstance(IndexProducer.class);
//this line always needs to be last due to the temporary cicular dependency until spring is removed
this.applicationIdCache = injector.getInstance(ApplicationIdCacheFactory.class).getInstance(
@@ -202,7 +199,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
private EntityManager _getEntityManager( UUID applicationId ) {
EntityManager em = new CpEntityManager(cassandraService, counterUtils, indexService, managerCache,
- metricsFactory, entityManagerFig, graphManagerFactory, collectionService, connectionService, indexProducer, applicationId );
+ metricsFactory, entityManagerFig, graphManagerFactory, collectionService, connectionService, applicationId );
return em;
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/34e0e632/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index c393fb2..cef0646 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import org.apache.usergrid.persistence.index.impl.IndexProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
@@ -106,7 +105,6 @@ public class CpRelationManager implements RelationManager {
private static final Logger logger = LoggerFactory.getLogger( CpRelationManager.class );
private final EntityManagerFig entityManagerFig;
- private final IndexProducer indexProducer;
private ManagerCache managerCache;
@@ -129,11 +127,10 @@ public class CpRelationManager implements RelationManager {
public CpRelationManager( final ManagerCache managerCache,
final AsyncEventService indexService, final CollectionService collectionService,
- final ConnectionService connectionService,final IndexProducer indexProducer,
+ final ConnectionService connectionService,
final EntityManager em,
final EntityManagerFig entityManagerFig, final UUID applicationId,
final EntityRef headEntity) {
- this.indexProducer = indexProducer;
Assert.notNull( em, "Entity manager cannot be null" );
@@ -540,7 +537,8 @@ public class CpRelationManager implements RelationManager {
final EntityIndexBatch batch = ei.createBatch();
batch.deindex( indexScope, memberEntity );
//TODO: this should not happen here, needs to go to SQS
- indexProducer.put(batch).subscribe();
+ //indexProducer.put(batch).subscribe();
+ indexService.queueEntityDelete(applicationScope,memberEntity.getId());
// special handling for roles collection of a group
if ( headEntity.getType().equals( Group.ENTITY_TYPE ) ) {
http://git-wip-us.apache.org/repos/asf/usergrid/blob/34e0e632/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
index 4bf5695..620bea8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
@@ -22,6 +22,7 @@ package org.apache.usergrid.corepersistence.asyncevents;
import java.util.List;
+import org.apache.usergrid.utils.UUIDUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -140,9 +141,10 @@ public class EventBuilderImpl implements EventBuilder {
//If there is nothing marked then we shouldn't return any results.
//TODO: evaluate if we want to return null or return empty observable when we don't have any results marked as deleted.
- if(mostRecentlyMarked == null)
- return null;
-
+ if(mostRecentlyMarked == null) {
+ Observable<IndexOperationMessage> messageObservable = indexService.deleteEntityIndexes(applicationScope, entityId, UUIDUtils.MAX_TIME_UUID);
+ return new EntityDeleteResults(messageObservable, Observable.<List<MvccLogEntry>>empty());
+ }
//observable of index operation messages
//this method will need the most recent version.
//When we go to compact the graph make sure you turn on the debugging mode for the deleted nodes so
[04/25] usergrid git commit: removing async processing
Posted by sn...@apache.org.
removing async processing
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/65bb2086
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/65bb2086
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/65bb2086
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 65bb2086e6735e8696022c14358351127783436a
Parents: aa57e24
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 15:09:28 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 15:09:28 2015 -0600
----------------------------------------------------------------------
.../apache/usergrid/corepersistence/CoreModule.java | 4 ----
.../usergrid/corepersistence/CpEntityManager.java | 9 ---------
.../corepersistence/index/IndexServiceImpl.java | 4 ----
.../corepersistence/StaleIndexCleanupTest.java | 14 +++++---------
.../index/impl/EsEntityIndexBatchImpl.java | 5 +----
.../index/impl/EsIndexBufferConsumerImpl.java | 4 +---
6 files changed, 7 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/65bb2086/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index e290cfe..9292531 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -52,14 +52,10 @@ public class CoreModule extends AbstractModule {
- public static final String EVENTS_DISABLED = "corepersistence.events.disabled";
-
-
@Override
protected void configure() {
-
install( new CommonModule());
install( new CollectionModule() {
/**
http://git-wip-us.apache.org/repos/asf/usergrid/blob/65bb2086/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index dc3d6a2..d46c112 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -2627,15 +2627,6 @@ public class CpEntityManager implements EntityManager {
handleWriteUniqueVerifyException( entity, wuve );
}
-
- // Index CP entity into default collection scope
- // IndexScope defaultIndexScope = new IndexScopeImpl(
- // applicationScope.getApplication(),
- // applicationScope.getApplication(),
- // CpEntityManager.getCollectionScopeNameFromEntityType( entity.getType() ) );
- // EntityIndex ei = managerCache.getEntityIndex( applicationScope );
- // ei.createBatch().index( defaultIndexScope, cpEntity ).execute();
-
// reflect changes in the legacy Entity
entity.setUuid( cpEntity.getId().getUuid() );
entity.setProperties( cpEntity );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/65bb2086/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
index 3ca33a3..8a8dba1 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceImpl.java
@@ -104,10 +104,6 @@ public class IndexServiceImpl implements IndexService {
//do our observable for batching
//try to send a whole batch if we can
-
-
- //do our observable for batching
- //try to send a whole batch if we can
final Observable<IndexOperationMessage> batches = sourceEdgesToIndex.buffer( indexFig.getIndexBatchSize() )
//map into batches based on our buffer size
http://git-wip-us.apache.org/repos/asf/usergrid/blob/65bb2086/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index 832409b..366d41c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -60,7 +60,6 @@ import com.google.inject.Injector;
import net.jcip.annotations.NotThreadSafe;
-import static org.apache.usergrid.corepersistence.CoreModule.EVENTS_DISABLED;
import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
import static org.junit.Assert.assertEquals;
@@ -73,6 +72,7 @@ import static org.junit.Assert.assertTrue;
@NotThreadSafe
public class StaleIndexCleanupTest extends AbstractCoreIT {
private static final Logger logger = LoggerFactory.getLogger( StaleIndexCleanupTest.class );
+ public static final String EVENTS_DISABLED = "corepersistence.events.disabled";
// take it easy on Cassandra
private static final long writeDelayMs = 0;
@@ -379,7 +379,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
app.refreshIndex();
Thread.sleep(250); // refresh happens asynchronously, wait for some time
-
+
//we can't use our candidate result sets here. The repair won't happen since we now have orphaned documents in our index
//us the EM so the repair process happens
@@ -401,7 +401,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
* Test that the EntityDeleteImpl cleans up stale indexes on update. Ensures that when an
* entity is updated its old indexes are cleared from ElasticSearch.
*/
- @Test(timeout=30000)
+ @Test()
public void testCleanupOnUpdate() throws Exception {
logger.info( "Started testCleanupOnUpdate()" );
@@ -425,20 +425,17 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
app.refreshIndex();
CandidateResults crs = queryCollectionCp( "dogs", "dog", "select *");
- Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
+ Assert.assertEquals("Expect no stale candidates yet", numEntities, crs.size());
// turn off post processing stuff that cleans up stale entities
- System.setProperty( EVENTS_DISABLED, "false" );
// update each entity a bunch of times
- List<Entity> maxVersions = new ArrayList<>(numEntities);
int count = 0;
for ( Entity dog : dogs ) {
- Entity toUpdate = null;
for ( int j=0; j<numUpdates; j++) {
- toUpdate = em.get( dog.getUuid() );
+ Entity toUpdate = em.get( dog.getUuid() );
toUpdate.setProperty( "property", RandomStringUtils.randomAlphanumeric(10));
em.update(toUpdate);
count++;
@@ -447,7 +444,6 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
}
}
- maxVersions.add( toUpdate );
}
app.refreshIndex();
http://git-wip-us.apache.org/repos/asf/usergrid/blob/65bb2086/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index 87b2368..c11feed 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -123,10 +123,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
@Override
public Observable execute() {
- IndexOperationMessage tempContainer = container;
- container = new IndexOperationMessage();
-
- return indexBatchBufferProducer.put( tempContainer );
+ return indexBatchBufferProducer.put( container );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/65bb2086/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
index 2066b51..4679483 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
@@ -98,7 +98,6 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
Preconditions.checkNotNull(message, "Message cannot be null");
indexSizeCounter.inc(message.getDeIndexRequests().size());
indexSizeCounter.inc(message.getIndexRequests().size());
-
return processBatch(message);
}
@@ -187,8 +186,7 @@ public class EsIndexBufferConsumerImpl implements IndexBufferConsumer {
try {
responses = bulkRequest.execute().actionGet( );
- }
- catch ( Throwable t ) {
+ } catch ( Throwable t ) {
log.error( "Unable to communicate with elasticsearch" );
failureMonitor.fail( "Unable to execute batch", t );
throw t;
[09/25] usergrid git commit: fix tests
Posted by sn...@apache.org.
fix tests
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/ba829c81
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/ba829c81
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/ba829c81
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: ba829c816da2cfcadd4d237f32a6d8ec1a50f372
Parents: c03a729
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 08:28:44 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 08:28:44 2015 -0600
----------------------------------------------------------------------
.../apache/usergrid/persistence/index/impl/EntityIndexTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/ba829c81/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 2fd9d3b..b8136fa 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -292,7 +292,7 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch entityIndexBatch = entityIndex.createBatch();
entityIndexBatch.deindex(searchEdge, crs.get(0));
- indexProducer.put(entityIndex.createBatch() ).subscribe();
+ indexProducer.put(entityIndexBatch ).subscribe();
entityIndex.refreshAsync().toBlocking().first();
//Hilda Youn
[25/25] usergrid git commit: Plug our Cassandra backed auth-info
cache into Shiro, some tests are failing with the new cache.
Posted by sn...@apache.org.
Plug our Cassandra backed auth-info cache into Shiro, some tests are failing with the new cache.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/dc7681f4
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/dc7681f4
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/dc7681f4
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: dc7681f471aee41148c1931cf55f976a29d1a99e
Parents: 08934c2
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Sep 22 11:15:26 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Sep 22 11:15:26 2015 -0400
----------------------------------------------------------------------
stack/core/pom.xml | 9 ++-
.../usergrid/corepersistence/CoreModule.java | 2 +
.../usergrid/persistence/cache/ScopedCache.java | 10 ++-
.../persistence/cache/guice/CacheModule.java | 7 +-
.../persistence/cache/impl/ScopedCacheImpl.java | 13 +++-
.../cache/impl/ScopedCacheSerialization.java | 7 +-
.../impl/ScopedCacheSerializationImpl.java | 50 ++++++++++--
.../persistence/cache/CacheTestModule.java | 16 +++-
.../persistence/cache/ScopedCacheTest.java | 44 ++++++++---
.../rest/security/shiro/ShiroCache.java | 80 ++++++++++++++++----
.../rest/security/shiro/ShiroCacheManager.java | 17 ++++-
.../collection/users/PermissionsResourceIT.java | 6 +-
stack/rest/src/test/resources/log4j.properties | 1 +
.../services/guice/ServiceModuleImpl.java | 45 ++++++-----
14 files changed, 236 insertions(+), 71 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index be2d28c..7944d96 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -423,6 +423,7 @@
<scope>test</scope>
</dependency>
+
<!-- Core Persistence deps -->
<dependency>
<groupId>org.apache.usergrid</groupId>
@@ -463,7 +464,13 @@
<type>jar</type>
</dependency>
- <dependency>
+ <dependency>
+ <groupId>org.apache.usergrid</groupId>
+ <artifactId>cache</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>queue</artifactId>
<version>2.1.0-SNAPSHOT</version>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 959edec..ae69b6f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -16,6 +16,7 @@
package org.apache.usergrid.corepersistence;
+import org.apache.usergrid.persistence.cache.guice.CacheModule;
import org.safehaus.guicyfig.GuicyFigModule;
import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
@@ -82,6 +83,7 @@ public class CoreModule extends AbstractModule {
protected void configure() {
install( new CommonModule());
+ install( new CacheModule());
install( new CollectionModule() {
/**
* configure our migration data provider for all entities in the system
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/ScopedCache.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/ScopedCache.java b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/ScopedCache.java
index 29c08c8..23377d0 100644
--- a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/ScopedCache.java
+++ b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/ScopedCache.java
@@ -17,17 +17,23 @@
package org.apache.usergrid.persistence.cache;
+import com.fasterxml.jackson.core.type.TypeReference;
+
/**
* Cache divided into scopes which can be individually invalidated.
*/
public interface ScopedCache<K,V> {
/** Put value into scope with ttl (null for no ttl) */
- void put( K key, V value, Integer ttl );
+ V put( K key, V value, Integer ttl );
/** Get value from scope */
- V get( K key );
+ V get( K key, TypeReference typeRef );
+
+ /** Delete a specific cached item */
+ void remove( K key );
/** Delete all cache data of all types in this scope */
void invalidate();
+
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/guice/CacheModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/guice/CacheModule.java b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/guice/CacheModule.java
index d744fcf..981cea7 100644
--- a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/guice/CacheModule.java
+++ b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/guice/CacheModule.java
@@ -39,13 +39,8 @@ public class CacheModule extends AbstractModule {
protected void configure() {
bind( CacheFactory.class ).to( CacheFactoryImpl.class );
- bind( ScopedCacheSerialization.class ).to( ScopedCacheSerializationImpl.class );
-
- bind( new TypeLiteral<CacheFactory<String, Map<String, Object>>>() {} )
- .to(new TypeLiteral<CacheFactoryImpl<String, Map<String, Object>>>() {});
- bind( new TypeLiteral<ScopedCacheSerialization<String, Map<String, Object>>>() {} )
- .to(new TypeLiteral<ScopedCacheSerializationImpl<String, Map<String, Object>>>() {});
+ bind( ScopedCacheSerialization.class ).to( ScopedCacheSerializationImpl.class );
Multibinder<Migration> migrationBinding = Multibinder.newSetBinder( binder(), Migration.class );
migrationBinding.addBinding().to(Key.get(ScopedCacheSerialization.class));
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheImpl.java b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheImpl.java
index 7e3bbf7..23a6573 100644
--- a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheImpl.java
+++ b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheImpl.java
@@ -16,6 +16,7 @@
*/
package org.apache.usergrid.persistence.cache.impl;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.google.inject.Inject;
import org.apache.usergrid.persistence.cache.CacheScope;
import org.apache.usergrid.persistence.cache.ScopedCache;
@@ -36,13 +37,17 @@ public class ScopedCacheImpl<K,V> implements ScopedCache<K,V> {
}
@Override
- public void put(K key, V value, Integer ttl) {
- serializer.writeValue( scope, key, value, ttl );
+ public V put(K key, V value, Integer ttl) {
+ return serializer.writeValue( scope, key, value, ttl );
}
@Override
- public V get(K key) {
- return serializer.readValue( scope, key );
+ public V get(K key, TypeReference typeRef ) {
+ return serializer.readValue( scope, key, typeRef );
+ }
+
+ public void remove( K key ) {
+ serializer.removeValue( scope, key );
}
@Override
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerialization.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerialization.java b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerialization.java
index 7ef5882..0ff690d 100644
--- a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerialization.java
+++ b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerialization.java
@@ -17,6 +17,7 @@
package org.apache.usergrid.persistence.cache.impl;
+import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.usergrid.persistence.cache.CacheScope;
import org.apache.usergrid.persistence.core.migration.schema.Migration;
@@ -26,9 +27,11 @@ import org.apache.usergrid.persistence.core.migration.schema.Migration;
*/
public interface ScopedCacheSerialization<K,V> extends Migration {
- V readValue( CacheScope scope, K key );
+ V readValue( CacheScope scope, K key, TypeReference typeRef );
- void writeValue( CacheScope scope, K key, V value, Integer ttl );
+ V writeValue( CacheScope scope, K key, V value, Integer ttl );
+
+ void removeValue( CacheScope scope, K key );
void invalidate( CacheScope scope );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerializationImpl.java b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerializationImpl.java
index 899d0bf..3fc7332 100644
--- a/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerializationImpl.java
+++ b/stack/corepersistence/cache/src/main/java/org/apache/usergrid/persistence/cache/impl/ScopedCacheSerializationImpl.java
@@ -20,10 +20,12 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.smile.SmileFactory;
import com.google.common.base.Preconditions;
import com.google.common.hash.Funnel;
import com.google.common.hash.PrimitiveSink;
import com.google.inject.Inject;
+import com.netflix.astyanax.ColumnListMutation;
import com.netflix.astyanax.Keyspace;
import com.netflix.astyanax.MutationBatch;
import com.netflix.astyanax.Serializer;
@@ -97,9 +99,9 @@ public class ScopedCacheSerializationImpl<K,V> implements ScopedCacheSerializati
private final Keyspace keyspace;
- private final JsonFactory JSON_FACTORY = new JsonFactory();
+ private final SmileFactory SMILE_FACTORY = new SmileFactory();
- private final ObjectMapper MAPPER = new ObjectMapper( JSON_FACTORY );
+ private final ObjectMapper MAPPER = new ObjectMapper( SMILE_FACTORY );
//------------------------------------------------------------------------------------------
@@ -111,7 +113,7 @@ public class ScopedCacheSerializationImpl<K,V> implements ScopedCacheSerializati
@Override
- public V readValue(CacheScope scope, K key) {
+ public V readValue(CacheScope scope, K key, TypeReference typeRef ) {
Preconditions.checkNotNull(scope, "scope is required");
Preconditions.checkNotNull(key, "key is required");
@@ -131,7 +133,12 @@ public class ScopedCacheSerializationImpl<K,V> implements ScopedCacheSerializati
.getKey(keyRowKey).getColumn( columnName ).execute().getResult();
result.getByteBufferValue();
- V value = MAPPER.readValue(result.getByteArrayValue(), new TypeReference<V>() {});
+ //V value = MAPPER.readValue(result.getByteArrayValue(), new TypeReference<V>() {});
+ V value = MAPPER.readValue(result.getByteArrayValue(), typeRef);
+
+ logger.info("Read cache item\n key/value types {}/{}\n key:value: {}:{}",
+ new Object[] { key.getClass().getSimpleName(), value.getClass().getSimpleName(), key, value });
+
return value;
} catch (NotFoundException nfe) {
@@ -145,12 +152,14 @@ public class ScopedCacheSerializationImpl<K,V> implements ScopedCacheSerializati
throw new RuntimeException("Unable to connect to cassandra", e);
}
+ logger.info("Cache value not found for key {}", key );
+
return null;
}
@Override
- public void writeValue(CacheScope scope, K key, V value, Integer ttl) {
+ public V writeValue(CacheScope scope, K key, V value, Integer ttl) {
Preconditions.checkNotNull( scope, "scope is required");
Preconditions.checkNotNull( key, "key is required" );
@@ -163,7 +172,7 @@ public class ScopedCacheSerializationImpl<K,V> implements ScopedCacheSerializati
final int bucket = BUCKET_LOCATOR.getCurrentBucket(rowKeyString);
final BucketScopedRowKey<String> keyRowKey =
- BucketScopedRowKey.fromKey( scope.getApplication(), rowKeyString, bucket);
+ BucketScopedRowKey.fromKey(scope.getApplication(), rowKeyString, bucket);
// determine column name based on K key to string
String columnName = key.toString();
@@ -181,6 +190,35 @@ public class ScopedCacheSerializationImpl<K,V> implements ScopedCacheSerializati
batch.withRow(SCOPED_CACHE, keyRowKey).putColumn(columnName, cacheBytes, ttl);
executeBatch(batch);
+
+ logger.info("Wrote cache item\n key/value types {}/{}\n key:value: {}:{}",
+ new Object[]{key.getClass().getSimpleName(), value.getClass().getSimpleName(), key, value});
+
+ return value;
+ }
+
+
+ @Override
+ public void removeValue(CacheScope scope, K key) {
+
+ Preconditions.checkNotNull( scope, "scope is required");
+ Preconditions.checkNotNull( key, "key is required" );
+
+ // determine bucketed row-key based application UUID
+
+ String rowKeyString = scope.getApplication().getUuid().toString();
+ final int bucket = BUCKET_LOCATOR.getCurrentBucket(rowKeyString);
+
+ final BucketScopedRowKey<String> keyRowKey =
+ BucketScopedRowKey.fromKey(scope.getApplication(), rowKeyString, bucket);
+
+ // determine column name based on K key to string
+ String columnName = key.toString();
+
+ final MutationBatch batch = keyspace.prepareMutationBatch();
+ batch.withRow(SCOPED_CACHE, keyRowKey).deleteColumn(columnName);
+
+ executeBatch(batch);
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/CacheTestModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/CacheTestModule.java b/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/CacheTestModule.java
index 47f6ccf..cb4caba 100644
--- a/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/CacheTestModule.java
+++ b/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/CacheTestModule.java
@@ -20,15 +20,29 @@
package org.apache.usergrid.persistence.cache;
+import com.google.inject.TypeLiteral;
import org.apache.usergrid.persistence.cache.guice.CacheModule;
+import org.apache.usergrid.persistence.cache.impl.CacheFactoryImpl;
+import org.apache.usergrid.persistence.cache.impl.ScopedCacheSerialization;
+import org.apache.usergrid.persistence.cache.impl.ScopedCacheSerializationImpl;
import org.apache.usergrid.persistence.core.guice.CommonModule;
+import java.util.Map;
+
public class CacheTestModule extends org.apache.usergrid.persistence.core.guice.TestModule {
@Override
protected void configure() {
- install( new CommonModule());
+
+ install( new CommonModule() );
install( new CacheModule() );
+
+ bind( new TypeLiteral<CacheFactory<String, Map<String, Object>>>() {} )
+ .to(new TypeLiteral<CacheFactoryImpl<String, Map<String, Object>>>() { });
+
+ bind( new TypeLiteral<ScopedCacheSerialization<String, Map<String, Object>>>() {} )
+ .to(new TypeLiteral<ScopedCacheSerializationImpl<String, Map<String, Object>>>() { });
+
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java b/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
index c37bd8b..c497141 100644
--- a/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
+++ b/stack/corepersistence/cache/src/test/java/org/apache/usergrid/persistence/cache/ScopedCacheTest.java
@@ -20,12 +20,12 @@
package org.apache.usergrid.persistence.cache;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.google.inject.Inject;
import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,7 +35,6 @@ import java.util.Map;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertNull;
-import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertEquals;
@@ -48,6 +47,8 @@ public class ScopedCacheTest {
@Inject protected CacheFactory<String, Map<String, Object>> cf;
+ TypeReference typeRef = new TypeReference<Map<String, Object>>() {};
+
@Test
public void testBasicOperation() {
@@ -61,7 +62,7 @@ public class ScopedCacheTest {
}};
cache.put("item", item, 60);
- Map<String, Object> retrievedItem = cache.get("item");
+ Map<String, Object> retrievedItem = cache.get("item", typeRef);
assertNotNull( "should get back item", retrievedItem );
assertEquals("value1", retrievedItem.get("field1"));
}
@@ -90,11 +91,11 @@ public class ScopedCacheTest {
}};
cache2.put("item", item, 60);
- Map<String, Object> fetched1 = cache1.get("item");
+ Map<String, Object> fetched1 = cache1.get("item", typeRef);
assertNotNull( "should get back item", fetched1 );
assertEquals("a_value", fetched1.get("field"));
- Map<String, Object> fetched2 = cache2.get("item");
+ Map<String, Object> fetched2 = cache2.get("item", typeRef);
assertNotNull( "should get back item", fetched2 );
assertEquals("another_value", fetched2.get("field"));
}
@@ -114,13 +115,13 @@ public class ScopedCacheTest {
}};
cache.put("item", item, 60);
- Map<String, Object> retrievedItem = cache.get("item");
+ Map<String, Object> retrievedItem = cache.get("item", typeRef);
assertNotNull( "should get back item", retrievedItem );
assertEquals("value1", retrievedItem.get("field1"));
cache.invalidate();
- assertNull(cache.get("item"));
+ assertNull(cache.get("item", typeRef));
}
@@ -138,12 +139,35 @@ public class ScopedCacheTest {
}};
cache.put("item", item, 1);
- Map<String, Object> retrievedItem = cache.get("item");
- assertNotNull( "should get back item", retrievedItem );
+ Map<String, Object> retrievedItem = cache.get("item", typeRef);
+ assertNotNull("should get back item", retrievedItem);
assertEquals("value1", retrievedItem.get("field1"));
try { Thread.sleep(1000); } catch (InterruptedException ignored) {}
- assertNull( cache.get("item"));
+ assertNull( cache.get("item", typeRef));
+ }
+
+ @Test
+ public void testRemove() {
+
+ CacheScope scope = new CacheScope( new SimpleId( "application" ) );
+ ScopedCache<String, Map<String, Object>> cache = cf.getScopedCache(scope);
+ assertNotNull("should get a cache", cache);
+
+ // cache item for 1 second
+
+ Map<String, Object> item = new HashMap<String, Object>() {{
+ put("field1", "value1");
+ }};
+ cache.put("item", item, 1);
+
+ Map<String, Object> retrievedItem = cache.get("item", typeRef);
+ assertNotNull( "should get back item", retrievedItem );
+ assertEquals("value1", retrievedItem.get("field1"));
+
+ cache.remove("item");
+
+ assertNull( cache.get("item", typeRef));
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
index bdc0e2f..03152b0 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCache.java
@@ -16,12 +16,21 @@
*/
package org.apache.usergrid.rest.security.shiro;
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
+import org.apache.shiro.subject.SimplePrincipalCollection;
+import org.apache.usergrid.persistence.cache.CacheFactory;
+import org.apache.usergrid.persistence.cache.CacheScope;
+import org.apache.usergrid.persistence.cache.ScopedCache;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.security.shiro.principals.AdminUserPrincipal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
+import java.util.Collections;
import java.util.Set;
@@ -31,48 +40,91 @@ import java.util.Set;
public class ShiroCache<K, V> implements Cache<K,V> {
private static final Logger logger = LoggerFactory.getLogger( ShiroCacheManager.class );
- private Cache<K,V> wrappedCache;
- public ShiroCache(Cache<K,V> ehc) {
- this.wrappedCache = ehc;
+ CacheFactory<String, V> cacheFactory;
+
+ TypeReference typeRef = new TypeReference<SimpleAuthorizationInfo>() {};
+
+
+ public ShiroCache( CacheFactory<String, V> cacheFactory ) {
+ this.cacheFactory = cacheFactory;
}
@Override
public V get(K key) throws CacheException {
- V value = wrappedCache.get(key);
- //logger.debug("SnoopCache: Returning key = {} value = {}", key, value);
- return value;
+ ScopedCache<String, V> scopedCache = getCacheScope(key);
+ if ( scopedCache != null ) {
+ return scopedCache.get( getKeyString(key), typeRef);
+ }
+ return null;
}
@Override
public V put(K key, V value) throws CacheException {
- logger.debug( "SnoopCache: Key class={} value value={}",
- key.getClass().getSimpleName(), value.getClass().getSimpleName() );
- return wrappedCache.put(key, value);
+ ScopedCache<String, V> scopedCache = getCacheScope(key);
+ if ( scopedCache != null ) {
+ return scopedCache.put( getKeyString(key) , value, 5000);
+ }
+ return null;
}
@Override
public V remove(K key) throws CacheException {
- return remove(key);
+ ScopedCache<String, V> scopedCache = getCacheScope(key);
+ if ( scopedCache != null ) {
+ scopedCache.remove( getKeyString(key) );
+ }
+ return null;
}
@Override
public void clear() throws CacheException {
- wrappedCache.clear();
}
@Override
public int size() {
- return wrappedCache.size();
+ return 0;
}
@Override
public Set<K> keys() {
- return wrappedCache.keys();
+ return Collections.EMPTY_SET;
}
@Override
public Collection<V> values() {
- return wrappedCache.values();
+ return Collections.EMPTY_LIST;
+ }
+
+
+ /** get cache for application scope */
+ private ScopedCache<String, V> getCacheScope( K key ) {
+
+ if ( key instanceof SimplePrincipalCollection) {
+ SimplePrincipalCollection spc = (SimplePrincipalCollection)key;
+
+ if ( spc.getPrimaryPrincipal() instanceof AdminUserPrincipal ) {
+ AdminUserPrincipal p = (AdminUserPrincipal) spc.getPrimaryPrincipal();
+ CacheScope scope = new CacheScope(new SimpleId(p.getApplicationId(), "application"));
+ ScopedCache<String, V> scopedCache = cacheFactory.getScopedCache(scope);
+ return scopedCache;
+ }
+ }
+ return null;
+ }
+
+
+ /** key is the application UUID in string form */
+ private String getKeyString( K key ) {
+
+ if ( key instanceof SimplePrincipalCollection) {
+ SimplePrincipalCollection spc = (SimplePrincipalCollection)key;
+
+ if ( spc.getPrimaryPrincipal() instanceof AdminUserPrincipal ) {
+ AdminUserPrincipal p = (AdminUserPrincipal) spc.getPrimaryPrincipal();
+ return p.getApplicationId().toString();
+ }
+ }
+ return null;
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java
index 5aaef9f..8ad9bd5 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroCacheManager.java
@@ -16,11 +16,21 @@
*/
package org.apache.usergrid.rest.security.shiro;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
+import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;
+import org.apache.shiro.subject.SimplePrincipalCollection;
+import org.apache.usergrid.corepersistence.GuiceFactory;
+import org.apache.usergrid.persistence.cache.CacheFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Map;
/**
@@ -30,11 +40,16 @@ public class ShiroCacheManager implements CacheManager {
private static final Logger logger = LoggerFactory.getLogger( ShiroCacheManager.class );
+ @Autowired
+ protected Injector injector;
+
public ShiroCacheManager() {
}
@Override
public <K, V> Cache<K, V> getCache(String name) throws CacheException {
- return new ShiroCache( null ); // TODO: plugin our cache here
+ return new ShiroCache( injector.getInstance(
+ Key.get(new TypeLiteral<CacheFactory<String, SimpleAuthorizationInfo>>() {}))
+ );
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
index 49d7c00..f5cb60c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
@@ -36,10 +36,8 @@ import static org.junit.Assert.*;
/**
- * Tests permissions of adding and removing users from roles as well as groups
- *
+ * Tests permissions of adding and removing users from roles as well as groups.
*/
-
public class PermissionsResourceIT extends AbstractRestIT {
private static final String ROLE = "permtestrole";
@@ -53,7 +51,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
}
- /**
+ /*hi
* Creates a user in the default org/app combo for use by all of the tests
*/
@Before
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/rest/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/log4j.properties b/stack/rest/src/test/resources/log4j.properties
index 0288842..41d2a94 100644
--- a/stack/rest/src/test/resources/log4j.properties
+++ b/stack/rest/src/test/resources/log4j.properties
@@ -29,6 +29,7 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
log4j.logger.org.glassfish=DEBUG
log4j.logger.org.apache.shiro=DEBUG
log4j.logger.org.apache.usergrid=INFO
+log4j.logger.org.apache.usergrid.persistence.cache=DEBUG
#log4j.logger.org.apache.usergrid.cassandra=DEBUG
#log4j.logger.org.apache.usergrid.persistence.cassandra=DEBUG
http://git-wip-us.apache.org/repos/asf/usergrid/blob/dc7681f4/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java b/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
index 1bcc881..ef680f0 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
@@ -19,36 +19,35 @@
package org.apache.usergrid.services.guice;
-import org.apache.usergrid.corepersistence.CoreModule;
+import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+import org.apache.shiro.authz.SimpleAuthorizationInfo;
+import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.usergrid.corepersistence.ServiceModule;
import org.apache.usergrid.management.AppInfoMigrationPlugin;
-import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.cache.CacheFactory;
+import org.apache.usergrid.persistence.cache.impl.CacheFactoryImpl;
+import org.apache.usergrid.persistence.cache.impl.ScopedCacheSerialization;
+import org.apache.usergrid.persistence.cache.impl.ScopedCacheSerializationImpl;
import org.apache.usergrid.persistence.core.migration.data.MigrationPlugin;
-import org.apache.usergrid.services.ServiceManager;
-import org.apache.usergrid.services.ServiceManagerFactory;
-import org.apache.usergrid.services.queues.ImportQueueListener;
-import com.google.inject.AbstractModule;
-import com.google.inject.assistedinject.FactoryModuleBuilder;
-import com.google.inject.multibindings.Multibinder;
+import java.util.Map;
-/**
- * Module that handles all of the guice injects for services.
- */
-
+// <bean id="notificationsQueueListener" class="org.apache.usergrid.services.notifications.QueueListener"
+// scope="singleton">
+// <constructor-arg name="emf" ref="entityManagerFactory" />
+// <constructor-arg name="metricsService" ref="metricsFactory" />
+// <constructor-arg name="props" ref="properties" />
+// <constructor-arg name="smf" ref="serviceManagerFactory" />
+// </bean>
/**
- * <bean id="notificationsQueueListener" class="org.apache.usergrid.services.notifications.QueueListener"
- scope="singleton">
- <constructor-arg name="emf" ref="entityManagerFactory" />
- <constructor-arg name="metricsService" ref="metricsFactory" />
- <constructor-arg name="props" ref="properties" />
- <constructor-arg name="smf" ref="serviceManagerFactory" />
- </bean>
+ * Module that handles all of the guice injects for services.
*/
-
public class ServiceModuleImpl extends AbstractModule implements ServiceModule {
+
@Override
protected void configure() {
@@ -56,5 +55,11 @@ public class ServiceModuleImpl extends AbstractModule implements ServiceModule {
final Multibinder<MigrationPlugin> plugins = Multibinder.newSetBinder( binder(), MigrationPlugin.class );
plugins.addBinding().to(AppInfoMigrationPlugin.class);
+ bind( new TypeLiteral<CacheFactory<String, SimpleAuthorizationInfo>>() {} )
+ .to( new TypeLiteral<CacheFactoryImpl<String, SimpleAuthorizationInfo>>() {});
+
+ bind( new TypeLiteral<ScopedCacheSerialization<String, SimpleAuthorizationInfo>>() {})
+ .to( new TypeLiteral<ScopedCacheSerializationImpl<String, SimpleAuthorizationInfo>>() {});
+
}
}
[24/25] usergrid git commit: Merge branch 'two-dot-o-dev' into
usergrid-1007-shiro-cache
Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-1007-shiro-cache
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/08934c2d
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/08934c2d
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/08934c2d
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 08934c2df0b86897cf59d78fb117e6cf788e5ea3
Parents: ee66318 a527d0d
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Sep 21 16:40:15 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Sep 21 16:40:15 2015 -0400
----------------------------------------------------------------------
stack/build-tools/pom.xml | 2 +-
stack/config/pom.xml | 2 +-
stack/core/pom.xml | 14 +++++++-------
stack/corepersistence/collection/pom.xml | 2 +-
stack/corepersistence/common/pom.xml | 2 +-
stack/corepersistence/graph/pom.xml | 2 +-
stack/corepersistence/map/pom.xml | 2 +-
stack/corepersistence/model/pom.xml | 2 +-
stack/corepersistence/pom.xml | 2 +-
stack/corepersistence/queryindex/pom.xml | 2 +-
stack/corepersistence/queue/pom.xml | 2 +-
stack/pom.xml | 2 +-
stack/rest/pom.xml | 2 +-
stack/services/pom.xml | 2 +-
stack/test-utils/pom.xml | 2 +-
15 files changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/08934c2d/stack/corepersistence/pom.xml
----------------------------------------------------------------------
[12/25] usergrid git commit: Merge branch 'USERGRID-1018' of
https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1022
Posted by sn...@apache.org.
Merge branch 'USERGRID-1018' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1022
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/f91f4e47
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/f91f4e47
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/f91f4e47
Branch: refs/heads/usergrid-1007-shiro-cache
Commit: f91f4e47715d7e2a9d77917b75464c24b7f2b336
Parents: ad2b825 fb1cf2e
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 10:27:31 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 10:27:31 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpRelationManager.java | 23 +-
.../asyncevents/AsyncEventService.java | 2 +
.../builder/PipelineBuilderFactory.java | 3 +
.../service/ConnectionScope.java | 53 +++++
.../service/ConnectionService.java | 10 +
.../service/ConnectionServiceImpl.java | 89 ++++++-
.../corepersistence/util/CpNamingUtils.java | 13 +-
.../corepersistence/TestCoreModule.java | 34 +++
.../service/ConnectionServiceImplTest.java | 235 +++++++++++++++++++
stack/core/src/test/resources/log4j.properties | 6 +-
.../core/astyanax/MultiRowColumnIterator.java | 2 +-
.../migration/schema/MigrationManagerFig.java | 1 +
.../graph/impl/GraphManagerImpl.java | 4 +-
.../impl/stage/EdgeDeleteListenerImpl.java | 4 +-
.../graph/impl/stage/EdgeDeleteRepairImpl.java | 61 ++---
.../impl/TargetIdObservableImpl.java | 13 +-
.../impl/shard/impl/EdgeSearcher.java | 14 +-
.../impl/ShardedEdgeSerializationImpl.java | 59 +++--
.../shard/impl/serialize/EdgeSerializer.java | 21 +-
.../persistence/graph/GraphManagerIT.java | 73 +++++-
20 files changed, 625 insertions(+), 95 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/f91f4e47/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------