You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/11/21 22:44:30 UTC
[21/28] incubator-usergrid git commit: Import cleanup and minor
formatting changes only.
Import cleanup and minor formatting changes only.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/74866a56
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/74866a56
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/74866a56
Branch: refs/heads/index-alias
Commit: 74866a566f1ec5b00a9f05412840988f597eb57d
Parents: d5616f6
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Nov 21 11:13:24 2014 +0100
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Nov 21 11:13:24 2014 +0100
----------------------------------------------------------------------
.../index/impl/EsEntityIndexBatchImpl.java | 66 +++++++-----
.../index/impl/EsEntityIndexImpl.java | 105 +++++++++----------
.../persistence/index/impl/EsProvider.java | 55 +---------
.../persistence/index/impl/EsQueryVistor.java | 3 +-
.../index/impl/FailureMonitorImpl.java | 4 +-
.../persistence/index/impl/IndexingUtils.java | 51 ++++-----
.../index/query/CandidateResults.java | 3 -
.../persistence/index/query/EntityResults.java | 4 +-
.../persistence/index/query/Identifier.java | 3 +-
.../usergrid/persistence/index/query/Query.java | 26 ++---
.../rest/test/resource/app/Collection.java | 20 +++-
11 files changed, 159 insertions(+), 181 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/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 c4cdeeb..4ce4d12 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
@@ -1,4 +1,4 @@
-package org.apache.usergrid.persistence.index.impl;/*
+/*
* 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
@@ -16,7 +16,7 @@ package org.apache.usergrid.persistence.index.impl;/*
* specific language governing permissions and limitations
* under the License.
*/
-
+package org.apache.usergrid.persistence.index.impl;
import java.util.ArrayList;
import java.util.Collection;
@@ -92,8 +92,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
private final FailureMonitor failureMonitor;
- public EsEntityIndexBatchImpl( final ApplicationScope applicationScope, final Client client, final IndexFig config,
- final int autoFlushSize, final FailureMonitor failureMonitor ) {
+ public EsEntityIndexBatchImpl( final ApplicationScope applicationScope, final Client client,
+ final IndexFig config, final int autoFlushSize, final FailureMonitor failureMonitor ) {
this.applicationScope = applicationScope;
this.client = client;
@@ -116,9 +116,14 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
if ( log.isDebugEnabled() ) {
log.debug( "Indexing entity {}:{} in scope\n app {}\n "
- + "owner {}\n name {}\n type {} \n scope type {}", new Object[] {
- entity.getId().getType(), entity.getId().getUuid(), applicationScope.getApplication(),
- indexScope.getOwner(), indexScope.getName(), entityType, context
+ + "owner {}\n name {}\n type {} \n scope type {}", new Object[] {
+ entity.getId().getType(),
+ entity.getId().getUuid(),
+ applicationScope.getApplication(),
+ indexScope.getOwner(),
+ indexScope.getName(),
+ entityType,
+ context
} );
}
@@ -137,7 +142,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
log.debug( "Indexing entity documentId {} data {} ", indexId, entityAsMap );
- bulkRequest.add( client.prepareIndex( indexName, entityType, indexId ).setSource( entityAsMap ) );
+ bulkRequest.add( client.prepareIndex(
+ indexName, entityType, indexId ).setSource( entityAsMap ) );
maybeFlush();
@@ -146,7 +152,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
@Override
- public EntityIndexBatch deindex( final IndexScope indexScope, final Id id, final UUID version ) {
+ public EntityIndexBatch deindex( final IndexScope indexScope, final Id id, final UUID version) {
IndexValidationUtils.validateIndexScope( indexScope );
ValidationUtils.verifyIdentity( id );
@@ -159,17 +165,24 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
if ( log.isDebugEnabled() ) {
- log.debug( "De-indexing entity {}:{} in scope\n app {}\n owner {}\n " + "name {} context{}, type {},",
- new Object[] {
- id.getType(), id.getUuid(), applicationScope.getApplication(), indexScope.getOwner(),
- indexScope.getName(), context, entityType
- } );
+ log.debug( "De-indexing entity {}:{} in scope\n app {}\n owner {}\n "
+ + "name {} context{}, type {},",
+ new Object[] {
+ id.getType(),
+ id.getUuid(),
+ applicationScope.getApplication(),
+ indexScope.getOwner(),
+ indexScope.getName(),
+ context,
+ entityType
+ } );
}
log.debug( "De-indexing type {} with documentId '{}'" , entityType, indexId);
- bulkRequest.add( client.prepareDelete( indexName, entityType, indexId ).setRefresh( refresh ) );
+ bulkRequest.add( client.prepareDelete(
+ indexName, entityType, indexId ).setRefresh( refresh ) );
log.debug( "Deindexed Entity with index id " + indexId );
@@ -225,8 +238,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
for ( BulkItemResponse response : responses ) {
if ( response.isFailed() ) {
- throw new RuntimeException(
- "Unable to index documents. Errors are :" + response.getFailure().getMessage() );
+ throw new RuntimeException( "Unable to index documents. Errors are :"
+ + response.getFailure().getMessage() );
}
}
@@ -262,9 +275,9 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
//add the context for filtering later
entityMap.put( ENTITY_CONTEXT_FIELDNAME, context );
- //but the fieldname
- //we have to prefix because we use query equality to seek this later. TODO see if we can make this more declarative
- entityMap.put( ENTITYID_ID_FIELDNAME, IndexingUtils.idString(entity.getId()).toLowerCase() );
+ //but the fieldname we have to prefix because we use query equality to seek this later.
+ // TODO see if we can make this more declarative
+ entityMap.put( ENTITYID_ID_FIELDNAME, IndexingUtils.idString(entity.getId()).toLowerCase());
return entityMap;
}
@@ -289,7 +302,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
if ( f instanceof ListField ) {
List list = ( List ) field.getValue();
- entityMap.put( field.getName().toLowerCase(), new ArrayList( processCollectionForMap( list ) ) );
+ entityMap.put( field.getName().toLowerCase(),
+ new ArrayList( processCollectionForMap( list ) ) );
if ( !list.isEmpty() ) {
if ( list.get( 0 ) instanceof String ) {
@@ -302,11 +316,13 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
}
else if ( f instanceof ArrayField ) {
List list = ( List ) field.getValue();
- entityMap.put( field.getName().toLowerCase(), new ArrayList( processCollectionForMap( list ) ) );
+ entityMap.put( field.getName().toLowerCase(),
+ new ArrayList( processCollectionForMap( list ) ) );
}
else if ( f instanceof SetField ) {
Set set = ( Set ) field.getValue();
- entityMap.put( field.getName().toLowerCase(), new ArrayList( processCollectionForMap( set ) ) );
+ entityMap.put( field.getName().toLowerCase(),
+ new ArrayList( processCollectionForMap( set ) ) );
}
else if ( f instanceof EntityObjectField ) {
EntityObject eo = ( EntityObject ) field.getValue();
@@ -329,7 +345,9 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
locMap.put( "lon", locField.getValue().getLongitude() );
entityMap.put( GEO_PREFIX + field.getName().toLowerCase(), locMap );
}
- else if ( f instanceof DoubleField || f instanceof FloatField || f instanceof IntegerField
+ else if ( f instanceof DoubleField
+ || f instanceof FloatField
+ || f instanceof IntegerField
|| f instanceof LongField ) {
entityMap.put( NUMBER_PREFIX + field.getName().toLowerCase(), field.getValue() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/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 b1e5374..22aa05c 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
@@ -74,7 +74,6 @@ import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITYID_ID_FIELDNAME;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.NUMBER_PREFIX;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.SPLITTER;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.STRING_PREFIX;
@@ -146,12 +145,13 @@ public class EsEntityIndexImpl implements EntityIndex {
final int numberOfShards = config.getNumberOfShards();
final int numberOfReplicas = config.getNumberOfReplicas();
- Settings settings = ImmutableSettings.settingsBuilder().put( "index.number_of_shards", numberOfShards )
- .put( "index.number_of_replicas", numberOfReplicas ).build();
+ Settings settings = ImmutableSettings.settingsBuilder()
+ .put( "index.number_of_shards", numberOfShards )
+ .put( "index.number_of_replicas", numberOfReplicas ).build();
- final CreateIndexResponse cir =
- admin.indices().prepareCreate( indexName ).setSettings( settings ).execute().actionGet();
+ final CreateIndexResponse cir = admin.indices().prepareCreate( indexName )
+ .setSettings( settings ).execute().actionGet();
logger.info( "Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged() );
@@ -186,17 +186,19 @@ public class EsEntityIndexImpl implements EntityIndex {
public boolean doOp() {
final String tempId = UUIDGenerator.newTimeUUID().toString();
- esProvider.getClient().prepareIndex( indexName, VERIFY_TYPE, tempId ).setSource( DEFAULT_PAYLOAD )
- .get();
+ esProvider.getClient().prepareIndex( indexName, VERIFY_TYPE, tempId )
+ .setSource( DEFAULT_PAYLOAD ).get();
- logger.info( "Successfully created new document with docId {} in index {} and type {}", tempId,
- indexName, VERIFY_TYPE );
+ logger.info( "Successfully created new document with docId {} in index {} type {}",
+ tempId, indexName, VERIFY_TYPE );
// delete all types, this way if we miss one it will get cleaned up
- esProvider.getClient().prepareDeleteByQuery( indexName ).setTypes( VERIFY_TYPE )
- .setQuery( MATCH_ALL_QUERY_BUILDER ).get();
+ esProvider.getClient().prepareDeleteByQuery( indexName )
+ .setTypes( VERIFY_TYPE )
+ .setQuery( MATCH_ALL_QUERY_BUILDER ).get();
- logger.info( "Successfully deleted all documents in index {} and type {}", indexName, VERIFY_TYPE );
+ logger.info( "Successfully deleted all documents in index {} and type {}",
+ indexName, VERIFY_TYPE );
return true;
}
@@ -207,36 +209,36 @@ public class EsEntityIndexImpl implements EntityIndex {
/**
- * Setup ElasticSearch type mappings as a template that applies to all new indexes. Applies to all indexes that
- * start with our prefix.
+ * Setup ElasticSearch type mappings as a template that applies to all new indexes.
+ * Applies to all indexes that* start with our prefix.
*/
private void createMappings() throws IOException {
- XContentBuilder xcb =
- IndexingUtils.createDoubleStringIndexMapping( XContentFactory.jsonBuilder(), "_default_" );
+ XContentBuilder xcb = IndexingUtils.createDoubleStringIndexMapping(
+ XContentFactory.jsonBuilder(), "_default_" );
- PutIndexTemplateResponse pitr =
- esProvider.getClient().admin().indices().preparePutTemplate( "usergrid_template" )
- .setTemplate( config.getIndexPrefix() + "*" ).addMapping( "_default_",
- xcb ) // set mapping as the default for all types
- .execute().actionGet();
+ PutIndexTemplateResponse pitr = esProvider.getClient().admin().indices()
+ .preparePutTemplate( "usergrid_template" )
+ // set mapping as the default for all types
+ .setTemplate( config.getIndexPrefix() + "*" ).addMapping( "_default_", xcb )
+ .execute().actionGet();
if(!pitr.isAcknowledged()){
throw new IndexException( "Unable to create default mappings" );
}
-
-
}
@Override
public EntityIndexBatch createBatch() {
- return new EsEntityIndexBatchImpl( applicationScope, esProvider.getClient(), config, 1000, failureMonitor );
+ return new EsEntityIndexBatchImpl(
+ applicationScope, esProvider.getClient(), config, 1000, failureMonitor );
}
@Override
- public CandidateResults search( final IndexScope indexScope, final SearchTypes searchTypes, final Query query ) {
+ public CandidateResults search( final IndexScope indexScope, final SearchTypes searchTypes,
+ final Query query ) {
final String context = IndexingUtils.createContextName( indexScope );
final String[] entityTypes = searchTypes.getTypeNames();
@@ -247,14 +249,12 @@ public class EsEntityIndexImpl implements EntityIndex {
SearchResponse searchResponse;
if ( query.getCursor() == null ) {
- SearchRequestBuilder srb = esProvider.getClient().prepareSearch( indexName ).setTypes( entityTypes )
- .setScroll( cursorTimeout + "m" ).setQuery( qb );
-
-
+ SearchRequestBuilder srb = esProvider.getClient().prepareSearch( indexName )
+ .setTypes( entityTypes )
+ .setScroll( cursorTimeout + "m" ).setQuery( qb );
final FilterBuilder fb = query.createFilterBuilder();
-
//we have post filters, apply them
if ( fb != null ) {
logger.debug( " Filter: {} ", fb.toString() );
@@ -280,21 +280,21 @@ public class EsEntityIndexImpl implements EntityIndex {
// to ignore any fields that are not present.
final String stringFieldName = STRING_PREFIX + sp.getPropertyName();
- final FieldSortBuilder stringSort =
- SortBuilders.fieldSort( stringFieldName ).order( order ).ignoreUnmapped( true );
+ final FieldSortBuilder stringSort = SortBuilders.fieldSort( stringFieldName )
+ .order( order ).ignoreUnmapped( true );
srb.addSort( stringSort );
logger.debug( " Sort: {} order by {}", stringFieldName, order.toString() );
final String numberFieldName = NUMBER_PREFIX + sp.getPropertyName();
- final FieldSortBuilder numberSort =
- SortBuilders.fieldSort( numberFieldName ).order( order ).ignoreUnmapped( true );
+ final FieldSortBuilder numberSort = SortBuilders.fieldSort( numberFieldName )
+ .order( order ).ignoreUnmapped( true );
srb.addSort( numberSort );
logger.debug( " Sort: {} order by {}", numberFieldName, order.toString() );
final String booleanFieldName = BOOLEAN_PREFIX + sp.getPropertyName();
- final FieldSortBuilder booleanSort =
- SortBuilders.fieldSort( booleanFieldName ).order( order ).ignoreUnmapped( true );
+ final FieldSortBuilder booleanSort = SortBuilders.fieldSort( booleanFieldName )
+ .order( order ).ignoreUnmapped( true );
srb.addSort( booleanSort );
logger.debug( " Sort: {} order by {}", booleanFieldName, order.toString() );
}
@@ -302,9 +302,8 @@ public class EsEntityIndexImpl implements EntityIndex {
if ( logger.isDebugEnabled() ) {
- logger.debug( "Searching index {}\n scope{} \n type {}\n query {} ", new Object[] {
- this.indexName, context, entityTypes, srb
- } );
+ logger.debug( "Searching index {}\n scope{} \n type {}\n query {} ",
+ new Object[] { this.indexName, context, entityTypes, srb } );
}
@@ -330,8 +329,8 @@ public class EsEntityIndexImpl implements EntityIndex {
}
logger.debug( "Executing query with cursor: {} ", scrollId );
- SearchScrollRequestBuilder ssrb =
- esProvider.getClient().prepareSearchScroll( scrollId ).setScroll( cursorTimeout + "m" );
+ SearchScrollRequestBuilder ssrb = esProvider.getClient()
+ .prepareSearchScroll( scrollId ).setScroll( cursorTimeout + "m" );
try {
searchResponse = ssrb.execute().actionGet();
@@ -392,7 +391,8 @@ public class EsEntityIndexImpl implements EntityIndex {
@Override
public boolean doOp() {
try {
- esProvider.getClient().admin().indices().prepareRefresh( indexName ).execute().actionGet();
+ esProvider.getClient().admin().indices().prepareRefresh( indexName )
+ .execute().actionGet();
logger.debug( "Refreshed index: " + indexName );
return true;
}
@@ -412,7 +412,8 @@ public class EsEntityIndexImpl implements EntityIndex {
@Override
public int getPendingTasks() {
- final PendingClusterTasksResponse tasksResponse = esProvider.getClient().admin().cluster().pendingClusterTasks( new PendingClusterTasksRequest() ).actionGet();
+ final PendingClusterTasksResponse tasksResponse = esProvider.getClient().admin()
+ .cluster().pendingClusterTasks( new PendingClusterTasksRequest() ).actionGet();
return tasksResponse.pendingTasks().size();
}
@@ -426,13 +427,12 @@ public class EsEntityIndexImpl implements EntityIndex {
final String context = IndexingUtils.createContextName( scope );
final SearchTypes searchTypes = SearchTypes.fromTypes( id.getType() );
- final QueryBuilder queryBuilder = QueryBuilders.termQuery( IndexingUtils.ENTITY_CONTEXT_FIELDNAME, context );
-
-
- final SearchRequestBuilder srb =
- esProvider.getClient().prepareSearch( indexName ).setTypes( searchTypes.getTypeNames() )
- .setScroll( cursorTimeout + "m" ).setQuery( queryBuilder );
+ final QueryBuilder queryBuilder = QueryBuilders.termQuery(
+ IndexingUtils.ENTITY_CONTEXT_FIELDNAME, context );
+ final SearchRequestBuilder srb = esProvider.getClient().prepareSearch( indexName )
+ .setTypes( searchTypes.getTypeNames() ).setScroll( cursorTimeout + "m" )
+ .setQuery( queryBuilder );
final SearchResponse searchResponse;
try {
@@ -499,8 +499,8 @@ public class EsEntityIndexImpl implements EntityIndex {
public Health getClusterHealth() {
try {
- ClusterHealthResponse chr =
- esProvider.getClient().admin().cluster().health( new ClusterHealthRequest() ).get();
+ ClusterHealthResponse chr = esProvider.getClient().admin()
+ .cluster().health( new ClusterHealthRequest() ).get();
return Health.valueOf( chr.getStatus().name() );
}
catch ( Exception ex ) {
@@ -520,8 +520,7 @@ public class EsEntityIndexImpl implements EntityIndex {
try {
ClusterHealthResponse chr = esProvider.getClient().admin().cluster()
- .health( new ClusterHealthRequest( new String[] { indexName } ) )
- .get();
+ .health( new ClusterHealthRequest( new String[] { indexName } ) ).get();
return Health.valueOf( chr.getStatus().name() );
}
catch ( Exception ex ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
index ea63ffc..2ea6774 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
@@ -25,10 +25,7 @@ import java.net.UnknownHostException;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
-import org.elasticsearch.node.Node;
-import org.elasticsearch.node.NodeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,11 +47,9 @@ public class EsProvider {
private final IndexFig indexFig;
private static Client client;
-// private static Node node;
public static String LOCAL_ES_PORT_PROPNAME = "EMBEDDED_ES_PORT";
-
@Inject
public EsProvider( IndexFig fig ) {
this.indexFig = fig;
@@ -86,28 +81,17 @@ public class EsProvider {
private synchronized void createClient( IndexFig fig ) {
-
if ( client != null) {
return;
}
-
-
final String clusterName = fig.getClusterName();
final int port = fig.getPort();
-
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
.put( "cluster.name", clusterName )
.put( "client.transport.sniff", true );
-
-
-// String allHosts = "";
-
-
-
-
String nodeName = fig.getNodeName();
if ( "default".equals( nodeName ) ) {
@@ -123,49 +107,12 @@ public class EsProvider {
settings.put( "node.name", nodeName);
-
-
TransportClient transportClient = new TransportClient( settings.build() );
+
// we will connect to ES on all configured hosts
-// String SEP = "";
for ( String host : fig.getHosts().split( "," ) ) {
-
transportClient.addTransportAddress( new InetSocketTransportAddress(host, port));
-
-// allHosts = allHosts + SEP + host + ":" + fig.getPort();
-// SEP = ",";
}
-
-// Settings settings = ImmutableSettings.settingsBuilder()
-//
-// .put( "cluster.name", fig.getClusterName() )
-//
-// // this assumes that we're using zen for host discovery. Putting an
-// // explicit set of bootstrap hosts ensures we connect to a valid cluster.
-// .put( "discovery.zen.ping.unicast.hosts", allHosts )
-// .put( "discovery.zen.ping.multicast.enabled", "false" ).put( "http.enabled", false )
-// .put("transport.tcp.port", "9300-9400")
-// .put( "client.transport.ping_timeout", 2000 ) // milliseconds
-// .put( "client.transport.nodes_sampler_interval", 100 )
-//// .put( "network.tcp.blocking", true )
-// .put( "node.client", true ).put( "node.name", nodeName+"Random test" )
-//
-// .build();
-
-// log.debug( "Creating ElasticSearch client with settings: " + settings.getAsMap() );
-//
-// // use this client when connecting via socket only,
-// // such as ssh tunnel or other firewall issues
-// // newClient = new TransportClient(settings).addTransportAddress(
-// // new InetSocketTransportAddress("localhost", 9300) );
-//
-// //use this client for quick connectivity
-// node = NodeBuilder.nodeBuilder().settings( settings ).client( true ).node();
-// client = node.client();
-
-
-
-// .build();
client = transportClient;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index 0e4b0ad..f012bab 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -222,7 +222,8 @@ public class EsQueryVistor implements QueryVisitor {
qb.minimumNumberShouldMatch(1);
// field is an entity/array that does not need a prefix on its name
- //TODO is this right now that we've updated our doc structure? Should this be "must" instead of should?
+ // TODO is this right now that we've updated our doc structure?
+ // Should this be "must" instead of should?
qb = qb.should( QueryBuilders.wildcardQuery( name, svalue ) );
// or field is just a string that does need a prefix
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
index eb17fac..fed9a50 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
@@ -75,8 +75,8 @@ public class FailureMonitorImpl implements FailureMonitor {
if ( fails > maxCount ) {
LOG.error( "Unable to connect to elasticsearch. Reason is {}", message, throwable );
- LOG.warn( "We have failed to connect to Elastic Search {} times. Max allowed is {}. Resetting connection",
- fails, maxCount );
+ LOG.warn( "We have failed to connect to Elastic Search {} times. "
+ + "Max allowed is {}. Resetting connection", fails, maxCount );
esProvider.releaseClient();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
index c7592bc..6d34b15 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
@@ -30,15 +30,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
public class IndexingUtils {
-
public static final String STRING_PREFIX = "su_";
public static final String ANALYZED_STRING_PREFIX = "sa_";
public static final String GEO_PREFIX = "go_";
public static final String NUMBER_PREFIX = "nu_";
public static final String BOOLEAN_PREFIX = "bu_";
-
-
public static final String SPLITTER = "\\__";
// These are not allowed in document type names: _ . , | #
@@ -156,7 +153,7 @@ public class IndexingUtils {
.startArray( "dynamic_templates" )
- //we need most specific mappings first since it's a stop on match algorithm
+ // we need most specific mappings first since it's a stop on match algorithm
.startObject()
.startObject( "context_template" )
@@ -168,51 +165,55 @@ public class IndexingUtils {
.endObject()
.endObject()
-
.startObject()
.startObject( "context_template" )
.field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
.field( "match_mapping_type", "string" )
- .startObject( "mapping" ).field( "type", "string" )
+ .startObject( "mapping" )
+ .field( "type", "string" )
.field( "index", "not_analyzed" ).endObject()
.endObject()
.endObject()
// any string with field name that starts with sa_ gets analyzed
.startObject()
- .startObject( "template_1" ).field( "match", ANALYZED_STRING_PREFIX + "*" )
- .field( "match_mapping_type", "string" ).startObject( "mapping" ).field( "type", "string" )
- .field( "index", "analyzed" ).endObject().endObject()
+ .startObject( "template_1" )
+ .field( "match", ANALYZED_STRING_PREFIX + "*" )
+ .field( "match_mapping_type", "string" ).startObject( "mapping" )
+ .field( "type", "string" )
+ .field( "index", "analyzed" )
+ .endObject()
.endObject()
+ .endObject()
- // all other strings are not analyzed
- .startObject()
- .startObject( "template_2" )
- //todo, should be string prefix, remove 2 field mapping
- .field( "match", "*" ).field( "match_mapping_type", "string" ).startObject( "mapping" )
+ // all other strings are not analyzed
+ .startObject()
+ .startObject( "template_2" )
+ //todo, should be string prefix, remove 2 field mapping
+ .field( "match", "*" )
+ .field( "match_mapping_type", "string" )
+ .startObject( "mapping" )
.field( "type", "string" )
.field( "index", "not_analyzed" )
- .endObject()
.endObject()
.endObject()
+ .endObject()
- // fields names starting with go_ get geo-indexed
- .startObject()
- .startObject( "template_3" )
- .field( "match", GEO_PREFIX + "location" )
+ // fields names starting with go_ get geo-indexed
+ .startObject()
+ .startObject( "template_3" )
+ .field( "match", GEO_PREFIX + "location" )
.startObject( "mapping" )
.field( "type", "geo_point" )
.endObject()
- .endObject()
.endObject()
+ .endObject()
+ .endArray()
+ .endObject()
- .endArray()
-
- .endObject()
-
- .endObject();
+ .endObject();
return builder;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
index a71bcbe..be90446 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
@@ -19,9 +19,6 @@ package org.apache.usergrid.persistence.index.query;
import java.util.Iterator;
import java.util.List;
-
-
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java
index b2aef93..59f20dd 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityResults.java
@@ -29,8 +29,8 @@ import org.apache.usergrid.persistence.model.entity.Entity;
/**
- * Loads results from candidate results. This needs to be refactored to the calling module, and should not exist in the
- * query index
+ * Loads results from candidate results. This needs to be refactored to the calling module,
+ * and should not exist in the query index
*/
public class EntityResults implements Iterable<Entity>, Iterator<Entity> {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
index 66dcd3b..9313c03 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
@@ -31,7 +31,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
public class Identifier implements Serializable {
- public static final String UUID_REX = "[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}";
+ public static final String UUID_REX =
+ "[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}";
public static final String EMAIL_REX = "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}";
public enum Type {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
index a057b02..414061d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
@@ -151,8 +151,9 @@ public class Query {
//we have a root operand. Translate our AST into an ES search
if ( getRootOperand() != null ) {
- //In the case of geo only queries, this will return null into the query builder. Once we start
- //using tiles, we won't need this check any longer, since a geo query will return a tile query + post filter
+ // In the case of geo only queries, this will return null into the query builder.
+ // Once we start using tiles, we won't need this check any longer, since a geo query
+ // will return a tile query + post filter
QueryVisitor v = new EsQueryVistor();
try {
@@ -167,14 +168,12 @@ public class Query {
}
- /**
- * Add our filter for context to our query for fast execution. Fast because it utilizes bitsets
- * internally. See this post for more detail.
- * http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/
- */
+ // Add our filter for context to our query for fast execution.
+ // Fast because it utilizes bitsets internally. See this post for more detail.
+ // http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/
-
- // TODO evaluate performance when it's an all query. Do we need to put the context term first for performance?
+ // TODO evaluate performance when it's an all query.
+ // Do we need to put the context term first for performance?
if ( queryBuilder != null ) {
queryBuilder = QueryBuilders.boolQuery().must( queryBuilder ).must( QueryBuilders
.termQuery( IndexingUtils.ENTITY_CONTEXT_FIELDNAME, context ) );
@@ -906,11 +905,12 @@ public class Query {
public void setLimit( int limit ) {
- // TODO tnine. After users have had time to change their query limits,
+ // TODO tnine. After users have had time to change their query limits,
// this needs to be uncommented and enforced.
- // if(limit > MAX_LIMIT){
- // throw new IllegalArgumentException(String.format("Query limit must be <= to %d", MAX_LIMIT));
- // }
+ // if(limit > MAX_LIMIT){
+ // throw new IllegalArgumentException(
+ // String.format("Query limit must be <= to %d", MAX_LIMIT));
+ // }
if ( limit > MAX_LIMIT ) {
limit = MAX_LIMIT;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/74866a56/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
index ac65a01..9101464 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/app/Collection.java
@@ -1,10 +1,24 @@
-package org.apache.usergrid.rest.test.resource.app;
+/*
+ * 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.test.resource.app;
import java.io.IOException;
import java.util.Map;
-import java.util.UUID;
-
import org.apache.usergrid.rest.test.resource.NamedResource;
import org.apache.usergrid.rest.test.resource.SetResource;
import org.apache.usergrid.utils.MapUtils;