You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/02/13 00:16:04 UTC
[09/10] incubator-usergrid git commit: First pass at removing
unnecessary 1.0 files.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/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 6e571d1..b0dba1d 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
@@ -17,24 +17,24 @@
package org.apache.usergrid.persistence;
-import org.apache.usergrid.persistence.index.query.Query;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import me.prettyprint.hector.api.mutation.Mutator;
import org.apache.usergrid.persistence.cassandra.CassandraService;
-import org.apache.usergrid.persistence.cassandra.GeoIndexManager;
import org.apache.usergrid.persistence.core.util.Health;
import org.apache.usergrid.persistence.entities.Application;
import org.apache.usergrid.persistence.entities.Role;
import org.apache.usergrid.persistence.index.query.CounterResolution;
import org.apache.usergrid.persistence.index.query.Identifier;
+import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.persistence.index.query.Query.Level;
+import me.prettyprint.hector.api.mutation.Mutator;
+
/**
* The interface class for the data access object for Applications. Each application contains a set of users as well as
@@ -42,9 +42,6 @@ import org.apache.usergrid.persistence.index.query.Query.Level;
*/
public interface EntityManager {
-// public void setApplicationId( UUID applicationId );
-
- public GeoIndexManager getGeoIndexManager();
public EntityRef getApplicationRef();
@@ -52,8 +49,6 @@ public interface EntityManager {
public void updateApplication( Application app ) throws Exception;
- public void updateApplication( Map<String, Object> properties ) throws Exception;
-
public RelationManager getRelationManager( EntityRef entityRef );
/** Get all collections for the application. Includes both user defined collections and schema collections */
@@ -89,7 +84,7 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- public Entity create( UUID importId, String entityType, Map<String, Object> properties )
+ public Entity create( UUID importId, String entityType, Map<String, Object> properties )
throws Exception;
public void createApplicationCollection( String entityType ) throws Exception;
@@ -103,7 +98,7 @@ public interface EntityManager {
* @param collectionName The name of the collection
* @param aliasValue The value of the alias
*/
- public EntityRef getAlias( EntityRef ownerRef, String collectionName, String aliasValue )
+ public EntityRef getAlias( EntityRef ownerRef, String collectionName, String aliasValue )
throws Exception;
public Map<String, EntityRef> getAlias( String aliasType, List<String> aliases ) throws Exception;
@@ -115,11 +110,11 @@ public interface EntityManager {
* @param collectionName The name of the collection
* @param aliases The alias property
*/
- public Map<String, EntityRef> getAlias( EntityRef ownerRef, String collectionName,
+ public Map<String, EntityRef> getAlias( EntityRef ownerRef, String collectionName,
List<String> aliases ) throws Exception;
/**
- * Validates that the entity exists in the datastore meaning that it exists and the type has
+ * Validates that the entity exists in the datastore meaning that it exists and the type has
* been loaded if not already provided.
*
* @return an validated EntityRef or null.
@@ -142,7 +137,7 @@ public interface EntityManager {
*
* @return a list of entity objects.
*/
- public Results get( Collection<UUID> entityIds, Class<? extends Entity> entityClass,
+ public Results get( Collection<UUID> entityIds, Class<? extends Entity> entityClass,
Level resultsLevel ) throws Exception;
/**
@@ -150,7 +145,7 @@ public interface EntityManager {
*
* @return a list of entity objects.
*/
- public Results get( Collection<UUID> entityIds, String entityType,
+ public Results get( Collection<UUID> entityIds, String entityType,
Class<? extends Entity> entityClass, Level resultsLevel ) throws Exception;
public Results getEntities(List<UUID> ids, String type);
@@ -175,13 +170,6 @@ public interface EntityManager {
public Object getProperty( EntityRef entityRef, String propertyName ) throws Exception;
/**
- * Do a single load of all entities with the given properties. Efficient if you have a subset of properties, and
- * know the ids of them. The entity UUID is in the key, the runtime subtype of Entity is in the value. Note that
- * if an entity cannot be loaded (id doesn't exist) it is simply ignored
- */
- public List<Entity> getPartialEntities( Collection<UUID> ids, Collection<String> properties ) throws Exception;
-
- /**
* Gets the properties for the specified entity property.
*
* @param entityRef an entity reference
@@ -222,13 +210,13 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- public void updateProperties( EntityRef entityRef, Map<String, Object> properties )
+ public void updateProperties( EntityRef entityRef, Map<String, Object> properties )
throws Exception;
public void deleteProperty( EntityRef entityRef, String propertyName ) throws Exception;
/**
- * Gets the values from an entity list property. Lists are a special type of entity property
+ * Gets the values from an entity list property. Lists are a special type of entity property
* that can contain an unordered set of non-duplicate values.
*
* @param entityRef an entity reference
@@ -238,11 +226,11 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- public Set<Object> getDictionaryAsSet( EntityRef entityRef, String dictionaryName )
+ public Set<Object> getDictionaryAsSet( EntityRef entityRef, String dictionaryName )
throws Exception;
/**
- * Adds the specified value to the named entity list property. Lists are a special type of
+ * Adds the specified value to the named entity list property. Lists are a special type of
* entity property that can contain an unordered set of non-duplicate values.
*
* @param entityRef an entity reference
@@ -251,26 +239,26 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementValue )
+ public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementValue )
throws Exception;
- public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementName,
+ public void addToDictionary( EntityRef entityRef, String dictionaryName, Object elementName,
Object elementValue ) throws Exception;
- public void addSetToDictionary( EntityRef entityRef, String dictionaryName,
+ public void addSetToDictionary( EntityRef entityRef, String dictionaryName,
Set<?> elementValues ) throws Exception;
- public void addMapToDictionary( EntityRef entityRef, String dictionaryName,
+ public void addMapToDictionary( EntityRef entityRef, String dictionaryName,
Map<?, ?> elementValues ) throws Exception;
- public Map<Object, Object> getDictionaryAsMap( EntityRef entityRef, String dictionaryName )
+ public Map<Object, Object> getDictionaryAsMap( EntityRef entityRef, String dictionaryName )
throws Exception;
- public Object getDictionaryElementValue( EntityRef entityRef, String dictionaryName,
+ public Object getDictionaryElementValue( EntityRef entityRef, String dictionaryName,
String elementName ) throws Exception;
/**
- * Removes the specified value to the named entity list property. Lists are a special type of
+ * Removes the specified value to the named entity list property. Lists are a special type of
* entity property that can contain an unordered set of non-duplicate values.
*
* @param entityRef an entity reference
@@ -293,17 +281,6 @@ public interface EntityManager {
*/
public void delete( EntityRef entityRef ) throws Exception;
- /**
- * Gets the entities and collections that the specified entity is a member of.
- *
- * @param entityRef an entity reference
- *
- * @return a map of entity references to set of collection names for the entities and
- * collections that this entity is a member of.
- *
- * @throws Exception the exception
- */
- public Map<String, Map<UUID, Set<String>>> getOwners( EntityRef entityRef ) throws Exception;
/**
* Return true if the owner entity ref is an owner of the entity;
@@ -312,7 +289,7 @@ public interface EntityManager {
* @param collectionName The collection name
* @param entity The entity in the collection
*/
- public boolean isCollectionMember( EntityRef owner, String collectionName, EntityRef entity )
+ public boolean isCollectionMember( EntityRef owner, String collectionName, EntityRef entity )
throws Exception;
/**
@@ -322,12 +299,12 @@ public interface EntityManager {
* @param connectionName The collection name
* @param entity The entity in the collection
*/
- public boolean isConnectionMember( EntityRef owner, String connectionName, EntityRef entity )
+ public boolean isConnectionMember( EntityRef owner, String connectionName, EntityRef entity )
throws Exception;
/**
- * Gets the collections for the specified entity. Collection for a given type are encoded
+ * Gets the collections for the specified entity. Collection for a given type are encoded
* in the schema, this method loads the entity type and returns the collections from the schema.
*
* @param entityRef an entity reference
@@ -391,20 +368,20 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- public void removeFromCollection( EntityRef entityRef, String collectionName, EntityRef itemRef)
+ public void removeFromCollection( EntityRef entityRef, String collectionName, EntityRef itemRef)
throws Exception;
- public Results searchCollection( EntityRef entityRef, String collectionName, Query query )
+ public Results searchCollection( EntityRef entityRef, String collectionName, Query query )
throws Exception;
- public Set<String> getCollectionIndexes( EntityRef entity, String collectionName )
+ public Set<String> getCollectionIndexes( EntityRef entity, String collectionName )
throws Exception;
- public void copyRelationships( EntityRef srcEntityRef, String srcRelationName,
+ public void copyRelationships( EntityRef srcEntityRef, String srcRelationName,
EntityRef dstEntityRef, String dstRelationName ) throws Exception;
/**
- * Connect the specified entity to another entity with the specified connection type.
+ * Connect the specified entity to another entity with the specified connection type.
* Connections are directional relationships that can be traversed in either direction.
*
* @throws Exception the exception
@@ -415,24 +392,24 @@ public interface EntityManager {
EntityRef connectedEntityRef ) throws Exception;
public ConnectionRef createConnection( EntityRef connectingEntity, String pairedConnectionType,
- EntityRef pairedEntity, String connectionType,
+ EntityRef pairedEntity, String connectionType,
EntityRef connectedEntityRef ) throws Exception;
- public ConnectionRef createConnection(
+ public ConnectionRef createConnection(
EntityRef connectingEntity, ConnectedEntityRef... connections )
throws Exception;
public ConnectionRef connectionRef( EntityRef connectingEntity, String connectionType,
EntityRef connectedEntityRef ) throws Exception;
- public ConnectionRef connectionRef( EntityRef connectingEntity, String pairedConnectionType,
- EntityRef pairedEntity, String connectionType, EntityRef connectedEntityRef )
+ public ConnectionRef connectionRef( EntityRef connectingEntity, String pairedConnectionType,
+ EntityRef pairedEntity, String connectionType, EntityRef connectedEntityRef )
throws Exception;
public ConnectionRef connectionRef( EntityRef connectingEntity, ConnectedEntityRef... connections );
/**
- * Disconnects two connected entities with the specified connection type. Connections are
+ * Disconnects two connected entities with the specified connection type. Connections are
* directional relationships that can be traversed in either direction.
*
* @throws Exception the exception
@@ -444,7 +421,7 @@ public interface EntityManager {
/**
- * Gets the entities of the specified type connected to the specified entity, optionally
+ * Gets the entities of the specified type connected to the specified entity, optionally
* matching the specified connection types and/or entity types. Returns a list of entity ids.
*
* @param entityId an entity reference
@@ -455,11 +432,11 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- public Results getConnectedEntities( EntityRef entityRef, String connectionType,
+ public Results getConnectedEntities( EntityRef entityRef, String connectionType,
String connectedEntityType, Level resultsLevel ) throws Exception;
/**
- * Gets the entities connecting to this entity, optionally with the specified connection
+ * Gets the entities connecting to this entity, optionally with the specified connection
* type and/or entity type.
* <p/>
* e.g. "get users who have favorited this place"
@@ -472,7 +449,7 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- public Results getConnectingEntities( EntityRef entityRef, String connectionType,
+ public Results getConnectingEntities( EntityRef entityRef, String connectionType,
String connectedEntityType, Level resultsLevel ) throws Exception;
public Results getConnectingEntities( EntityRef entityRef, String connectionType,
@@ -541,23 +518,17 @@ public interface EntityManager {
public void revokeUserPermission( UUID userId, String permission ) throws Exception;
- // User role membership
-
- public Map<String, String> getUserGroupRoles( UUID userId, UUID groupId ) throws Exception;
-
public void addUserToGroupRole( UUID userId, UUID groupId, String roleName ) throws Exception;
- public void removeUserFromGroupRole( UUID userId, UUID groupId, String roleName ) throws Exception;
-
public Results getUsersInGroupRole( UUID groupId, String roleName, Level level ) throws Exception;
- public void incrementAggregateCounters( UUID userId, UUID groupId, String category,
+ public void incrementAggregateCounters( UUID userId, UUID groupId, String category,
String counterName, long value );
- public Results getAggregateCounters( UUID userId, UUID groupId, String category,
+ public Results getAggregateCounters( UUID userId, UUID groupId, String category,
String counterName, CounterResolution resolution, long start, long finish, boolean pad );
- public Results getAggregateCounters( UUID userId, UUID groupId, UUID queueId, String category,
+ public Results getAggregateCounters( UUID userId, UUID groupId, UUID queueId, String category,
String counterName, CounterResolution resolution, long start, long finish, boolean pad );
public Results getAggregateCounters( Query query ) throws Exception;
@@ -572,10 +543,10 @@ public interface EntityManager {
public Map<String, Long> getApplicationCounters() throws Exception;
- public void incrementAggregateCounters(
+ public void incrementAggregateCounters(
UUID userId, UUID groupId, String category, Map<String, Long> counters );
- public boolean isPropertyValueUniqueForEntity(
+ public boolean isPropertyValueUniqueForEntity(
String entityType, String propertyName, Object propertyValue ) throws Exception;
@Deprecated
@@ -610,8 +581,8 @@ public interface EntityManager {
public void revokeGroupPermission( UUID groupId, String permission ) throws Exception;
- <A extends Entity> A batchCreate(Mutator<ByteBuffer> m, String entityType,
- Class<A> entityClass, Map<String, Object> properties,
+ <A extends Entity> A batchCreate(Mutator<ByteBuffer> m, String entityType,
+ Class<A> entityClass, Map<String, Object> properties,
UUID importId, UUID timestampUuid) throws Exception;
/**
* Batch dictionary property.
@@ -626,15 +597,15 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- Mutator<ByteBuffer> batchSetProperty(Mutator<ByteBuffer> batch, EntityRef entity,
+ Mutator<ByteBuffer> batchSetProperty(Mutator<ByteBuffer> batch, EntityRef entity,
String propertyName, Object propertyValue, UUID timestampUuid) throws Exception;
- Mutator<ByteBuffer> batchSetProperty(Mutator<ByteBuffer> batch, EntityRef entity,
- String propertyName, Object propertyValue, boolean force, boolean noRead,
+ Mutator<ByteBuffer> batchSetProperty(Mutator<ByteBuffer> batch, EntityRef entity,
+ String propertyName, Object propertyValue, boolean force, boolean noRead,
UUID timestampUuid) throws Exception;
- Mutator<ByteBuffer> batchUpdateDictionary(Mutator<ByteBuffer> batch, EntityRef entity,
- String dictionaryName, Object elementValue, Object elementCoValue,
+ Mutator<ByteBuffer> batchUpdateDictionary(Mutator<ByteBuffer> batch, EntityRef entity,
+ String dictionaryName, Object elementValue, Object elementCoValue,
boolean removeFromDictionary, UUID timestampUuid) throws Exception;
/**
@@ -651,30 +622,15 @@ public interface EntityManager {
*
* @throws Exception the exception
*/
- Mutator<ByteBuffer> batchUpdateDictionary(Mutator<ByteBuffer> batch, EntityRef entity,
- String dictionaryName, Object elementValue,
+ Mutator<ByteBuffer> batchUpdateDictionary(Mutator<ByteBuffer> batch, EntityRef entity,
+ String dictionaryName, Object elementValue,
boolean removeFromDictionary, UUID timestampUuid) throws Exception;
- /**
- * Batch update properties.
- *
- * @param batch the batch
- * @param entity The owning entity reference
- * @param properties the properties to set
- * @param timestampUuid the timestamp of the update operation as a time uuid
- *
- * @return batch
- *
- * @throws Exception the exception
- */
- Mutator<ByteBuffer> batchUpdateProperties(Mutator<ByteBuffer> batch,
- EntityRef entity, Map<String, Object> properties, UUID timestampUuid) throws Exception;
Set<String> getDictionaryNames(EntityRef entity) throws Exception;
- void insertEntity( EntityRef ref ) throws Exception;
- /** @return the applicationId */
+ /** @return the applicationId */
UUID getApplicationId();
/** @return the indexBucketLocator */
@@ -683,7 +639,7 @@ public interface EntityManager {
/** @return the cass */
CassandraService getCass();
- /**
+ /**
* Refresh the applications index -- use sparingly.
*/
void refreshIndex();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java b/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java
index 5b64d0b..52e235c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java
@@ -24,7 +24,7 @@ import org.apache.usergrid.persistence.index.query.Query.Level;
/**
- * For each in a set of source refs executes a sub-query and provides a unified iterator over
+ * For each in a set of source refs executes a sub-query and provides a unified iterator over
* the union of all results. Honors page sizes for the Query to ensure memory isn't blown out.
*/
public class MultiQueryIterator implements ResultsIterator {
@@ -36,10 +36,6 @@ public class MultiQueryIterator implements ResultsIterator {
private Iterator currentIterator;
- public MultiQueryIterator( Results results, Query query ) {
- this( results.getQueryProcessor().getEntityManager(),
- new PagingResultsIterator( results, Level.IDS ), query );
- }
public MultiQueryIterator( EntityManager entityManager, Iterator<EntityRef> source, Query query ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
index c543e75..28e0a50 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/RelationManager.java
@@ -57,12 +57,11 @@ public interface RelationManager {
public Entity addToCollections( List<EntityRef> owners, String collectionName ) throws Exception;
public Entity createItemInCollection( String collectionName, String itemType, Map<String, Object> properties )
- throws Exception;
+ throws Exception;
public void removeFromCollection( String collectionName, EntityRef itemRef ) throws Exception;
- public void copyRelationships( String srcRelationName, EntityRef dstEntityRef, String dstRelationName )
- throws Exception;
+ public void copyRelationships( String srcRelationName, EntityRef dstEntityRef, String dstRelationName ) throws Exception;
public Results searchCollection( String collectionName, Query query ) throws Exception;
@@ -75,8 +74,6 @@ public interface RelationManager {
public ConnectionRef createConnection( ConnectedEntityRef... connections ) throws Exception;
- public ConnectionRef connectionRef( String connectionType, EntityRef connectedEntityRef ) throws Exception;
-
public ConnectionRef connectionRef( String pairedConnectionType, EntityRef pairedEntity, String connectionType,
EntityRef connectedEntityRef ) throws Exception;
@@ -84,8 +81,6 @@ public interface RelationManager {
public void deleteConnection( ConnectionRef connectionRef ) throws Exception;
- public Set<String> getConnectionTypes( UUID connectedEntityId ) throws Exception;
-
public Set<String> getConnectionTypes() throws Exception;
public Set<String> getConnectionTypes( boolean filterConnection ) throws Exception;
@@ -96,11 +91,9 @@ public interface RelationManager {
* @param connectionType The type/name of the connection
* @param connectedEntityType The type of
*/
- public Results getConnectedEntities( String connectionType, String connectedEntityType, Level resultsLevel )
- throws Exception;
+ public Results getConnectedEntities( String connectionType, String connectedEntityType, Level resultsLevel ) throws Exception;
- public Results getConnectingEntities( String connectionType, String connectedEntityType,
- Level resultsLevel ) throws Exception;
+ public Results getConnectingEntities( String connectionType, String connectedEntityType, Level resultsLevel ) throws Exception;
// public Results searchConnectedEntitiesForProperty(String connectionType,
// String connectedEntityType, String propertyName,
@@ -108,14 +101,10 @@ public interface RelationManager {
// UUID startResult, int count, boolean reversed, Level resultsLevel)
// throws Exception;
- public Results getConnectingEntities(
- String connectionType, String entityType, Level level, int count) throws Exception;
+ public Results getConnectingEntities( String connectionType, String entityType, Level level, int count ) throws Exception;
- public Results searchConnectedEntities( Query query ) throws Exception;
+ public Results searchConnectedEntities( Query query ) throws Exception;
public Set<String> getConnectionIndexes( String connectionType ) throws Exception;
-
- public void batchUpdateSetIndexes( Mutator<ByteBuffer> batch, String setName, Object elementValue,
- boolean removeFromSet, UUID timestampUuid ) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java b/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java
index 388b29e..fa98f41 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/Results.java
@@ -30,10 +30,8 @@ import java.util.UUID;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.usergrid.persistence.cassandra.QueryProcessor;
import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.persistence.index.query.Query.Level;
-import org.apache.usergrid.persistence.query.ir.SearchVisitor;
import org.apache.usergrid.utils.MapUtils;
import org.apache.usergrid.utils.StringUtils;
@@ -82,8 +80,6 @@ public class Results implements Iterable<Entity> {
Object data;
String dataName;
- private QueryProcessor queryProcessor;
- private SearchVisitor searchVisitor;
public Results() {
@@ -1268,19 +1264,6 @@ public class Results implements Iterable<Entity> {
}
- protected QueryProcessor getQueryProcessor() {
- return queryProcessor;
- }
-
-
- public void setQueryProcessor( QueryProcessor queryProcessor ) {
- this.queryProcessor = queryProcessor;
- }
-
-
- public void setSearchVisitor( SearchVisitor searchVisitor ) {
- this.searchVisitor = searchVisitor;
- }
/** uses cursor to get next batch of Results (returns null if no cursor) */
@@ -1289,10 +1272,6 @@ public class Results implements Iterable<Entity> {
return null;
}
- Query q = new Query( query );
- q.setCursor( getCursor() );
- queryProcessor.setQuery( q );
-
- return queryProcessor.getResults( searchVisitor );
+ throw new UnsupportedOperationException( "This needs to be implemented" );
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
index 2322b95..01651cd 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
@@ -32,10 +32,6 @@ import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.locking.LockManager;
-import org.apache.usergrid.persistence.IndexBucketLocator;
-import org.apache.usergrid.persistence.IndexBucketLocator.IndexType;
-import org.apache.usergrid.persistence.cassandra.index.IndexBucketScanner;
-import org.apache.usergrid.persistence.cassandra.index.IndexScanner;
import org.apache.usergrid.persistence.hector.CountingMutator;
import org.apache.usergrid.utils.MapUtils;
@@ -1002,48 +998,10 @@ public class CassandraService {
- /**
- * Gets the id list.
- *
- * @param ko the keyspace
- * @param key the key
- * @param start the start
- * @param finish the finish
- * @param count the count
- * @param reversed True if the scan should be reversed
- * @param locator The index locator instance
- * @param applicationId The applicationId
- * @param collectionName The name of the collection to get the Ids for
- *
- * @return list of columns as UUIDs
- *
- * @throws Exception the exception
- */
- public IndexScanner getIdList( Keyspace ko, Object key, UUID start, UUID finish, int count, boolean reversed,
- IndexBucketLocator locator, UUID applicationId, String collectionName, boolean keepFirst )
- throws Exception {
-
- if ( count <= 0 ) {
- count = DEFAULT_COUNT;
- }
-
- if ( NULL_ID.equals( start ) ) {
- start = null;
- }
- final boolean skipFirst = start != null && !keepFirst;
-
- IndexScanner scanner =
- new IndexBucketScanner( this, locator, ENTITY_ID_SETS, applicationId, IndexType.COLLECTION, key, start,
- finish, reversed, count, skipFirst, collectionName );
-
- return scanner;
- }
-
-
public void destroy() throws Exception {
if (cluster != null) {
HConnectionManager connectionManager = cluster.getConnectionManager();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
deleted file mode 100644
index a598a82..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ /dev/null
@@ -1,490 +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.cassandra;
-
-
-import java.nio.ByteBuffer;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.apache.usergrid.persistence.DynamicEntity;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.entities.Application;
-import org.apache.usergrid.persistence.exceptions.ApplicationAlreadyExistsException;
-import org.apache.usergrid.persistence.hector.CountingMutator;
-import org.apache.usergrid.utils.UUIDUtils;
-
-import org.apache.commons.lang.StringUtils;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.yammer.metrics.annotation.Metered;
-
-import me.prettyprint.hector.api.Keyspace;
-import me.prettyprint.hector.api.beans.ColumnSlice;
-import me.prettyprint.hector.api.beans.HColumn;
-import me.prettyprint.hector.api.beans.OrderedRows;
-import me.prettyprint.hector.api.beans.Row;
-import me.prettyprint.hector.api.beans.Rows;
-import me.prettyprint.hector.api.mutation.Mutator;
-import me.prettyprint.hector.api.query.QueryResult;
-import me.prettyprint.hector.api.query.RangeSlicesQuery;
-
-import static java.lang.String.CASE_INSENSITIVE_ORDER;
-
-
-import static me.prettyprint.hector.api.factory.HFactory.createRangeSlicesQuery;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_UUID;
-import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.asMap;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.batchExecute;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.RETRY_COUNT;
-import static org.apache.usergrid.utils.ConversionUtils.uuid;
-import static org.apache.usergrid.persistence.cassandra.Serializers.*;
-import org.apache.usergrid.persistence.core.util.Health;
-
-
-/**
- * Cassandra-specific implementation of Datastore
- *
- * @author edanuff
- */
-public class EntityManagerFactoryImpl implements EntityManagerFactory, ApplicationContextAware {
-
- private static final Logger logger = LoggerFactory.getLogger( EntityManagerFactoryImpl.class );
-
- public static String IMPLEMENTATION_DESCRIPTION = "Cassandra Entity Manager Factory 1.0";
-
- public static final Class<DynamicEntity> APPLICATION_ENTITY_CLASS = DynamicEntity.class;
-
-
- ApplicationContext applicationContext;
-
- CassandraService cass;
- CounterUtils counterUtils;
-
- private boolean skipAggregateCounters;
-
- private LoadingCache<UUID, EntityManager> entityManagers =
- CacheBuilder.newBuilder().maximumSize( 100 ).build( new CacheLoader<UUID, EntityManager>() {
- public EntityManager load( UUID appId ) { // no checked exception
- return _getEntityManager( appId );
- }
- } );
-
- private static final int REBUILD_PAGE_SIZE = 100;
-
-
- /**
- * Must be constructed with a CassandraClientPool.
- *
- * @param cass the cassandraService instance
- */
- public EntityManagerFactoryImpl( CassandraService cass, CounterUtils counterUtils, boolean skipAggregateCounters ) {
- this.cass = cass;
- this.counterUtils = counterUtils;
- this.skipAggregateCounters = skipAggregateCounters;
- if ( skipAggregateCounters ) {
- logger.warn( "NOTE: Counters have been disabled by configuration..." );
- }
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.usergrid.core.Datastore#getImplementationDescription()
- */
- @Override
- public String getImplementationDescription() {
- return IMPLEMENTATION_DESCRIPTION;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.usergrid.core.Datastore#getEntityDao(java.util.UUID,
- * java.util.UUID)
- */
- @Override
- public EntityManager getEntityManager( UUID applicationId ) {
- try {
- return entityManagers.get( applicationId );
- }
- catch ( Exception ex ) {
- ex.printStackTrace();
- }
- return _getEntityManager( applicationId );
- }
-
-
- private EntityManager _getEntityManager( UUID applicationId ) {
- EntityManagerImpl em = new EntityManagerImpl();
- em.init( this, cass, counterUtils, applicationId, skipAggregateCounters );
- em.setApplicationId( applicationId );
- return em;
- }
-
-
- public ApplicationContext getApplicationContext() {
- return applicationContext;
- }
-
-
- /**
- * Gets the setup.
- *
- * @return Setup helper
- */
- public SetupImpl getSetup() {
- return new SetupImpl( this, cass );
- }
-
-
- @Override
- public void setup() throws Exception {
- Setup setup = getSetup();
- setup.init();
-
- if ( cass.getPropertiesMap() != null ) {
- updateServiceProperties( cass.getPropertiesMap() );
- }
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.usergrid.core.Datastore#createApplication(java.lang.String)
- */
- @Override
- public UUID createApplication( String organization, String name ) throws Exception {
- return createApplication( organization, name, null );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.usergrid.core.Datastore#createApplication(java.lang.String,
- * java.util.Map)
- */
- @Override
- public UUID createApplication( String organizationName, String name, Map<String, Object> properties )
- throws Exception {
-
- String appName = buildAppName( organizationName, name );
-
- HColumn<String, ByteBuffer> column =
- cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, appName, PROPERTY_UUID );
- if ( column != null ) {
- throw new ApplicationAlreadyExistsException( name );
- // UUID uuid = uuid(column.getValue());
- // return uuid;
- }
-
- UUID applicationId = UUIDUtils.newTimeUUID();
- logger.info( "New application id " + applicationId.toString() );
-
- initializeApplication( organizationName, applicationId, appName, properties );
-
- return applicationId;
- }
-
-
- @Override
- public void deleteApplication(UUID applicationId) throws Exception {
- // TODO implement deleteApplication in Usergrid 1 code base (master branch?)
- throw new UnsupportedOperationException("Not supported.");
- }
-
-
- private String buildAppName( String organizationName, String name ) {
- return StringUtils.lowerCase( name.contains( "/" ) ? name : organizationName + "/" + name );
- }
-
-
- public UUID initializeApplication( String organizationName, UUID applicationId, String name,
- Map<String, Object> properties ) throws Exception {
-
- String appName = buildAppName( organizationName, name );
- // check for pre-existing
- if ( lookupApplication( appName ) != null ) {
- throw new ApplicationAlreadyExistsException( appName );
- }
- if ( properties == null ) {
- properties = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
- }
-
- properties.put( PROPERTY_NAME, appName );
-
- getSetup().setupApplicationKeyspace( applicationId, appName );
-
- Keyspace ko = cass.getSystemKeyspace();
- Mutator<ByteBuffer> m = CountingMutator.createFlushingMutator( ko, be );
-
- long timestamp = cass.createTimestamp();
-
- addInsertToMutator( m, APPLICATIONS_CF, appName, PROPERTY_UUID, applicationId, timestamp );
- addInsertToMutator( m, APPLICATIONS_CF, appName, PROPERTY_NAME, appName, timestamp );
-
- batchExecute( m, RETRY_COUNT );
-
- EntityManager em = getEntityManager( applicationId );
- em.create( TYPE_APPLICATION, APPLICATION_ENTITY_CLASS, properties );
-
- em.resetRoles();
-
- return applicationId;
- }
-
-
- @Override
- public UUID importApplication( String organizationName, UUID applicationId, String name,
- Map<String, Object> properties ) throws Exception {
-
- name = buildAppName( organizationName, name );
-
- HColumn<String, ByteBuffer> column =
- cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
- if ( column != null ) {
- throw new ApplicationAlreadyExistsException( name );
- // UUID uuid = uuid(column.getValue());
- // return uuid;
- }
-
- return initializeApplication( organizationName, applicationId, name, properties );
- }
-
-
- @Override
- @Metered(group = "core", name = "EntityManagerFactory_lookupApplication_byName")
- public UUID lookupApplication( String name ) throws Exception {
- name = name.toLowerCase();
- HColumn<String, ByteBuffer> column =
- cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
- if ( column != null ) {
- return uuid( column.getValue() );
- }
- return null;
- }
-
-
- /**
- * Gets the application.
- *
- * @param name the name
- *
- * @return application for name
- *
- * @throws Exception the exception
- */
- @Metered(group = "core", name = "EntityManagerFactory_getApplication")
- public Application getApplication( String name ) throws Exception {
- name = name.toLowerCase();
- HColumn<String, ByteBuffer> column =
- cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
- if ( column == null ) {
- return null;
- }
-
- UUID applicationId = uuid( column.getValue() );
-
- EntityManager em = getEntityManager( applicationId );
- return ( ( EntityManagerImpl ) em ).getEntity( applicationId, Application.class );
- }
-
-
- @Override
- public Map<String, UUID> getApplications() throws Exception {
- Map<String, UUID> applications = new TreeMap<String, UUID>( CASE_INSENSITIVE_ORDER );
- Keyspace ko = cass.getSystemKeyspace();
- RangeSlicesQuery<String, String, UUID> q = createRangeSlicesQuery( ko, se, se, ue );
- q.setKeys( "", "\uFFFF" );
- q.setColumnFamily( APPLICATIONS_CF );
- q.setColumnNames( PROPERTY_UUID );
- q.setRowCount( 10000 );
- QueryResult<OrderedRows<String, String, UUID>> r = q.execute();
- Rows<String, String, UUID> rows = r.get();
- for ( Row<String, String, UUID> row : rows ) {
- ColumnSlice<String, UUID> slice = row.getColumnSlice();
- HColumn<String, UUID> column = slice.getColumnByName( PROPERTY_UUID );
- applications.put( row.getKey(), column.getValue() );
- }
- return applications;
- }
-
-
- @Override
- public boolean setServiceProperty( String name, String value ) {
- try {
- cass.setColumn( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name, value );
- return true;
- }
- catch ( Exception e ) {
- logger.error( "Unable to set property " + name + ": " + e.getMessage() );
- }
- return false;
- }
-
-
- @Override
- public boolean deleteServiceProperty( String name ) {
- try {
- cass.deleteColumn( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name );
- return true;
- }
- catch ( Exception e ) {
- logger.error( "Unable to delete property " + name + ": " + e.getMessage() );
- }
- return false;
- }
-
-
- @Override
- public boolean updateServiceProperties( Map<String, String> properties ) {
- try {
- cass.setColumns( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF.getBytes(), properties );
- return true;
- }
- catch ( Exception e ) {
- logger.error( "Unable to update properties: " + e.getMessage() );
- }
- return false;
- }
-
-
- @Override
- public Map<String, String> getServiceProperties() {
- try {
- return asMap( cass.getAllColumns( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, se, se ) );
- }
- catch ( Exception e ) {
- logger.error( "Unable to load properties: " + e.getMessage() );
- }
- return null;
- }
-
-
- @Override
- public void setApplicationContext( ApplicationContext applicationContext ) throws BeansException {
- this.applicationContext = applicationContext;
- }
-
-
- @Override
- public long performEntityCount() {
- throw new UnsupportedOperationException("Not supported in v1");
- }
-
-
- public void setCounterUtils( CounterUtils counterUtils ) {
- this.counterUtils = counterUtils;
- }
-
-
- static final UUID MANAGEMENT_APPLICATION_ID = new UUID( 0, 1 );
- static final UUID DEFAULT_APPLICATION_ID = new UUID( 0, 16 );
-
- @Override
- public UUID getManagementAppId() {
- return MANAGEMENT_APPLICATION_ID;
- }
-
- @Override
- public UUID getDefaultAppId() {
- return DEFAULT_APPLICATION_ID;
- }
-
- @Override
- public void refreshIndex() {
- // no op
- }
-
- @Override
- public void flushEntityManagerCaches() {
- // no-op
- }
-
- @Override
- public void rebuildInternalIndexes(ProgressObserver po) throws Exception {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public void rebuildAllIndexes(ProgressObserver po) throws Exception {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public void rebuildApplicationIndexes(UUID appId, ProgressObserver po) throws Exception {
- throw new UnsupportedOperationException("Not supported.");
- }
-
-
- @Override
- public void migrateData() throws Exception {
-
- }
-
-
- @Override
- public String getMigrateDataStatus() {
- throw new UnsupportedOperationException("Not supported in v1");
- }
-
-
- @Override
- public int getMigrateDataVersion() {
- throw new UnsupportedOperationException("Not supported in v1");
- }
-
-
- @Override
- public void setMigrationVersion( final int version ) {
- throw new UnsupportedOperationException("Not supported in v1");
- }
-
-
- @Override
- public void rebuildCollectionIndex(UUID appId, String collection, ProgressObserver po) {
- throw new UnsupportedOperationException("Not supported.");
- }
-
- @Override
- public void addIndex(UUID appId, String suffix,final int shards,final int replicas) {
- throw new UnsupportedOperationException("Not supported in v1");
- }
-
- @Override
- public Health getEntityStoreHealth() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-}