Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Commit

Permalink
Updates REST api calls. POST is used to create a re-index job, PUT is…
Browse files Browse the repository at this point in the history
… used to resume.

Also fixes transitive dependency issue with clouds
  • Loading branch information
Todd Nine committed May 16, 2015
1 parent 48be894 commit 5a7f9c0
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 206 deletions.
Expand Up @@ -22,8 +22,6 @@

import java.util.UUID;

import org.elasticsearch.action.index.IndexRequestBuilder;

import org.apache.usergrid.persistence.core.scope.ApplicationScope;

import com.google.common.base.Optional;
Expand All @@ -32,34 +30,34 @@
/**
* A builder interface to build our re-index request
*/
public interface IndexServiceRequestBuilder {
public interface ReIndexRequestBuilder {

/**
* Set the application id
*/
IndexServiceRequestBuilder withApplicationId( final UUID applicationId );
ReIndexRequestBuilder withApplicationId( final UUID applicationId );

/**
* Set the collection name. If not set, every collection will be reindexed
* @param collectionName
* @return
*/
IndexServiceRequestBuilder withCollection( final String collectionName );
ReIndexRequestBuilder withCollection( final String collectionName );

/**
* Set our cursor to resume processing
* @param cursor
* @return
*/
IndexServiceRequestBuilder withCursor(final String cursor);
ReIndexRequestBuilder withCursor(final String cursor);


/**
* Set the timestamp to re-index entities updated >= this timestamp
* @param timestamp
* @return
*/
IndexServiceRequestBuilder withStartTimestamp(final Long timestamp);
ReIndexRequestBuilder withStartTimestamp(final Long timestamp);


/**
Expand Down
Expand Up @@ -31,7 +31,7 @@
/**
* Index service request builder
*/
public class IndexServiceRequestBuilderImpl implements IndexServiceRequestBuilder {
public class ReIndexRequestBuilderImpl implements ReIndexRequestBuilder {

private Optional<UUID> withApplicationId = Optional.absent();
private Optional<String> withCollectionName = Optional.absent();
Expand All @@ -45,7 +45,7 @@ public class IndexServiceRequestBuilderImpl implements IndexServiceRequestBuilde
* @return
*/
@Override
public IndexServiceRequestBuilder withApplicationId( final UUID applicationId ) {
public ReIndexRequestBuilder withApplicationId( final UUID applicationId ) {
this.withApplicationId = Optional.fromNullable( applicationId );
return this;
}
Expand All @@ -57,7 +57,7 @@ public IndexServiceRequestBuilder withApplicationId( final UUID applicationId )
* @return
*/
@Override
public IndexServiceRequestBuilder withCollection( final String collectionName ) {
public ReIndexRequestBuilder withCollection( final String collectionName ) {
if(collectionName == null){
this.withCollectionName = Optional.absent();
}
Expand All @@ -74,7 +74,7 @@ public IndexServiceRequestBuilder withCollection( final String collectionName )
* @return
*/
@Override
public IndexServiceRequestBuilder withCursor( final String cursor ) {
public ReIndexRequestBuilder withCursor( final String cursor ) {
this.cursor = Optional.fromNullable( cursor );
return this;
}
Expand All @@ -86,7 +86,7 @@ public IndexServiceRequestBuilder withCursor( final String cursor ) {
* @return
*/
@Override
public IndexServiceRequestBuilder withStartTimestamp( final Long timestamp ) {
public ReIndexRequestBuilder withStartTimestamp( final Long timestamp ) {
this.updateTimestamp = Optional.fromNullable( timestamp );
return this;
}
Expand Down
Expand Up @@ -29,15 +29,15 @@ public interface ReIndexService {
/**
* Perform an index rebuild
*
* @param indexServiceRequestBuilder The builder to build the request
* @param reIndexRequestBuilder The builder to build the request
*/
ReIndexStatus rebuildIndex( final IndexServiceRequestBuilder indexServiceRequestBuilder );
ReIndexStatus rebuildIndex( final ReIndexRequestBuilder reIndexRequestBuilder );


/**
* Generate a build for the index
*/
IndexServiceRequestBuilder getBuilder();
ReIndexRequestBuilder getBuilder();


/**
Expand Down
Expand Up @@ -91,16 +91,16 @@ public ReIndexServiceImpl( final AllEntityIdsObservable allEntityIdsObservable,


@Override
public ReIndexStatus rebuildIndex( final IndexServiceRequestBuilder indexServiceRequestBuilder ) {
public ReIndexStatus rebuildIndex( final ReIndexRequestBuilder reIndexRequestBuilder ) {

//load our last emitted Scope if a cursor is present

final Optional<EdgeScope> cursor = parseCursor( indexServiceRequestBuilder.getCursor() );
final Optional<EdgeScope> cursor = parseCursor( reIndexRequestBuilder.getCursor() );


final CursorSeek<Edge> cursorSeek = getResumeEdge( cursor );

final Optional<ApplicationScope> appId = indexServiceRequestBuilder.getApplicationScope();
final Optional<ApplicationScope> appId = reIndexRequestBuilder.getApplicationScope();


Preconditions.checkArgument( !(cursor.isPresent() && appId.isPresent()),
Expand All @@ -111,11 +111,11 @@ public ReIndexStatus rebuildIndex( final IndexServiceRequestBuilder indexService

final String jobId = StringUtils.sanitizeUUID( UUIDGenerator.newTimeUUID() );

final long modifiedSince = indexServiceRequestBuilder.getUpdateTimestamp().or( Long.MIN_VALUE );
final long modifiedSince = reIndexRequestBuilder.getUpdateTimestamp().or( Long.MIN_VALUE );

//create an observable that loads each entity and indexes it, start it running with publish
final Observable<EdgeScope> runningReIndex = allEntityIdsObservable.getEdgesToEntities( applicationScopes,
indexServiceRequestBuilder.getCollectionName(), cursorSeek.getSeekValue() )
reIndexRequestBuilder.getCollectionName(), cursorSeek.getSeekValue() )

//for each edge, create our scope and index on it
.doOnNext( edge -> {
Expand Down Expand Up @@ -143,8 +143,8 @@ public ReIndexStatus rebuildIndex( final IndexServiceRequestBuilder indexService


@Override
public IndexServiceRequestBuilder getBuilder() {
return new IndexServiceRequestBuilderImpl();
public ReIndexRequestBuilder getBuilder() {
return new ReIndexRequestBuilderImpl();
}


Expand Down
Expand Up @@ -33,7 +33,7 @@

import org.apache.usergrid.AbstractCoreIT;
import org.apache.usergrid.cassandra.SpringResource;
import org.apache.usergrid.corepersistence.index.IndexServiceRequestBuilder;
import org.apache.usergrid.corepersistence.index.ReIndexRequestBuilder;
import org.apache.usergrid.corepersistence.index.ReIndexService;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
Expand Down Expand Up @@ -153,7 +153,7 @@ public void rebuildOneCollectionIndex() throws Exception {
logger.debug( "Preparing to rebuild all indexes" );


final IndexServiceRequestBuilder builder =
final ReIndexRequestBuilder builder =
reIndexService.getBuilder().withApplicationId( em.getApplicationId() ).withCollection( "catherders" );

ReIndexService.ReIndexStatus status = reIndexService.rebuildIndex( builder );
Expand Down Expand Up @@ -270,7 +270,7 @@ public void rebuildIndex() throws Exception {

try {

final IndexServiceRequestBuilder builder =
final ReIndexRequestBuilder builder =
reIndexService.getBuilder().withApplicationId( em.getApplicationId() );

ReIndexService.ReIndexStatus status = reIndexService.rebuildIndex( builder );
Expand Down
Expand Up @@ -99,6 +99,8 @@ public class IndexingUtils {

/**
* Create our sub scope. This is the ownerUUID + type
*
* TODO make this format more readable and parsable
*/
public static String createContextName( final ApplicationScope applicationScope, final SearchEdge scope ) {
StringBuilder sb = new StringBuilder();
Expand Down
13 changes: 13 additions & 0 deletions stack/pom.xml
Expand Up @@ -1241,6 +1241,13 @@
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${jclouds.version}</version>
<exclusions>
<!-- blows up our version of guice-->
<exclusion>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -1262,6 +1269,12 @@
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
</exclusion>

<!-- blows up our version of guice-->
<exclusion>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down

0 comments on commit 5a7f9c0

Please sign in to comment.