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 2014/10/27 21:03:12 UTC
[2/6] git commit: Clean up no longer used classes and tests.
Clean up no longer used classes and tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/57c28ba3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/57c28ba3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/57c28ba3
Branch: refs/heads/two-dot-o-events
Commit: 57c28ba3342d53537a883fbab1851fd8d612059a
Parents: 63bcf8d
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Oct 27 10:29:19 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Oct 27 10:29:19 2014 -0400
----------------------------------------------------------------------
.../corepersistence/CpEntityDeleteListener.java | 95 ----------------
.../CpEntityIndexDeleteListener.java | 98 ----------------
.../CpEntityDeleteListenerTest.java | 92 ---------------
.../CpEntityIndexDeleteListenerTest.java | 114 -------------------
4 files changed, 399 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/57c28ba3/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
deleted file mode 100644
index 70df7d5..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
+++ /dev/null
@@ -1,95 +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.corepersistence;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityDeleteEvent;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
-import org.apache.usergrid.persistence.core.entity.EntityVersion;
-import org.apache.usergrid.persistence.core.rx.ObservableIterator;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.netflix.astyanax.Keyspace;
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
-import rx.Observable;
-import rx.functions.Func1;
-import rx.schedulers.Schedulers;
-
-/**
- * Listener for cleans up old entities and deletes from data store
- */
-@Singleton
-public class CpEntityDeleteListener {
- private static final Logger LOG = LoggerFactory.getLogger(CpEntityDeleteListener.class);
-
- private final MvccEntitySerializationStrategy entityMetadataSerialization;
- private final Keyspace keyspace;
- private final SerializationFig serializationFig;
-
- @Inject
- public CpEntityDeleteListener(final MvccEntitySerializationStrategy entityMetadataSerialization,
- final Keyspace keyspace,
- final SerializationFig serializationFig){
- this.entityMetadataSerialization = entityMetadataSerialization;
- this.keyspace = keyspace;
- this.serializationFig = serializationFig;
- }
-
-
- public Observable<EntityVersion> receive(final MvccEntityDeleteEvent entityEvent) {
- final MvccEntity entity = entityEvent.getEntity();
- return Observable.create( new ObservableIterator<MvccEntity>( "deleteEntities" ) {
- @Override
- protected Iterator<MvccEntity> getIterator() {
- Iterator<MvccEntity> iterator = entityMetadataSerialization.loadHistory( entityEvent.getCollectionScope(), entity.getId(), entity.getVersion(), serializationFig.getHistorySize() );
- return iterator;
- }
- } ).subscribeOn(Schedulers.io())
- .buffer(serializationFig.getBufferSize())
- .flatMap(new Func1<List<MvccEntity>, Observable<EntityVersion>>() {
- @Override
- public Observable<EntityVersion> call(List<MvccEntity> mvccEntities) {
- MutationBatch mutationBatch = keyspace.prepareMutationBatch();
- List<EntityVersion> versions = new ArrayList<>();
- //actually delete the edge from both the commit log and
- for (MvccEntity mvccEntity : mvccEntities) {
- versions.add(mvccEntity);
- mutationBatch.mergeShallow(entityMetadataSerialization.delete(entityEvent.getCollectionScope(), mvccEntity.getId(), mvccEntity.getVersion()));
- }
- try {
- mutationBatch.execute();
- } catch (ConnectionException e) {
- throw new RuntimeException("Unable to execute mutation", e);
- }
- return Observable.from(versions);
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/57c28ba3/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java
deleted file mode 100644
index 125b90b..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListener.java
+++ /dev/null
@@ -1,98 +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.corepersistence;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityDeleteEvent;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
-import org.apache.usergrid.persistence.core.entity.EntityVersion;
-import org.apache.usergrid.persistence.core.rx.ObservableIterator;
-import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
-import org.apache.usergrid.persistence.index.query.CandidateResult;
-import org.apache.usergrid.persistence.index.query.CandidateResults;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-import rx.Observable;
-import rx.functions.Func1;
-import rx.schedulers.Schedulers;
-
-
-/**
- * Listener for cleans up old indexes and deletes from indexer
- */
-@Singleton
-public class CpEntityIndexDeleteListener {
-
- private final SerializationFig serializationFig;
- private final EntityIndexFactory entityIndexFactory;
-
-
- @Inject
- public CpEntityIndexDeleteListener(final EntityIndexFactory entityIndexFactory,
- SerializationFig serializationFig) {
- this.entityIndexFactory = entityIndexFactory;
- this.serializationFig = serializationFig;
- }
-
-
- public Observable<EntityVersion> receive(final MvccEntityDeleteEvent event) {
-
- final CollectionScope collectionScope = event.getCollectionScope();
- final IndexScope indexScope =
- new IndexScopeImpl(collectionScope.getOwner(), collectionScope.getName());
- final EntityIndex entityIndex = entityIndexFactory.createEntityIndex(
- new ApplicationScopeImpl( collectionScope.getApplication()));
-
- return Observable.create(new ObservableIterator<CandidateResult>("deleteEsIndexVersions") {
- @Override
- protected Iterator<CandidateResult> getIterator() {
- CandidateResults results =
- entityIndex.getEntityVersions(indexScope, event.getEntity().getId());
- return results.iterator();
- }
- }).subscribeOn(Schedulers.io())
- .buffer(serializationFig.getBufferSize())
- .flatMap(new Func1<List<CandidateResult>, Observable<? extends EntityVersion>>() {
-
- @Override
- public Observable<? extends EntityVersion> call(List<CandidateResult> crs) {
- List<EntityVersion> versions = new ArrayList<>();
- for (CandidateResult entity : crs) {
- //filter find entities <= current version
- if (entity.getVersion().timestamp() <= event.getVersion().timestamp()) {
- versions.add(entity);
- entityIndex.createBatch()
- .deindex(indexScope, entity.getId(), entity.getVersion());
- }
- }
- return Observable.from(versions);
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/57c28ba3/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityDeleteListenerTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityDeleteListenerTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityDeleteListenerTest.java
deleted file mode 100644
index 16d2e79..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityDeleteListenerTest.java
+++ /dev/null
@@ -1,92 +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.corepersistence;
-
-
-import java.util.ArrayList;
-import java.util.UUID;
-
-import org.jukito.JukitoRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityDeleteEvent;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
-import org.apache.usergrid.persistence.core.entity.EntityVersion;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-
-import com.netflix.astyanax.Keyspace;
-import com.netflix.astyanax.MutationBatch;
-
-import rx.Observable;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(JukitoRunner.class)
-public class CpEntityDeleteListenerTest {
-
-
- protected MvccEntitySerializationStrategy mvccEntitySerializationStrategy;
-
- protected CpEntityDeleteListener listener;
-
- protected SerializationFig serializationFig;
-
- protected Keyspace keyspace;
-
- @Before
- public void setup() {
- serializationFig = mock(SerializationFig.class);
- keyspace = mock(Keyspace.class);
- mvccEntitySerializationStrategy = mock(MvccEntitySerializationStrategy.class);
-
- listener = new CpEntityDeleteListener(mvccEntitySerializationStrategy, keyspace, serializationFig);
- }
-
- @Test
- public void receive() {
- CollectionScope scope = mock(CollectionScope.class);
- UUID id = UUID.randomUUID();
- MvccEntity entity = mock(MvccEntity.class);
- Id entityId = new SimpleId(id, "test");
- when(entity.getId()).thenReturn(entityId);
- when(entity.getVersion()).thenReturn(id);
- MvccEntityDeleteEvent entityEvent = new MvccEntityDeleteEvent(scope, id, entity);
- MutationBatch batch = mock(MutationBatch.class);
- when(keyspace.prepareMutationBatch()).thenReturn(batch);
- when(serializationFig.getBufferSize()).thenReturn(10);
- when(serializationFig.getHistorySize()).thenReturn(20);
-
- ArrayList<MvccEntity> entityList = new ArrayList<>();
- entityList.add(entity);
- when(mvccEntitySerializationStrategy.delete(scope, entityId, id)).thenReturn(batch);
- when(mvccEntitySerializationStrategy.loadHistory(scope, entityId, id, serializationFig.getHistorySize())).thenReturn(entityList.iterator());
-
- Observable<EntityVersion> observable = listener.receive(entityEvent);
- EntityVersion entityEventReturned = observable.toBlocking().last();
- assertEquals(entity.getVersion(), entityEventReturned.getVersion());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/57c28ba3/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListenerTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListenerTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListenerTest.java
deleted file mode 100644
index 6b92d90..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/CpEntityIndexDeleteListenerTest.java
+++ /dev/null
@@ -1,114 +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.corepersistence;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.UUID;
-
-import org.jukito.JukitoRunner;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityDeleteEvent;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
-import org.apache.usergrid.persistence.core.entity.EntityVersion;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.query.CandidateResult;
-import org.apache.usergrid.persistence.index.query.CandidateResults;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-
-import com.netflix.astyanax.util.TimeUUIDUtils;
-
-import rx.Observable;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith( JukitoRunner.class )
-@Ignore("Needs updated")
-public class CpEntityIndexDeleteListenerTest {
- EntityIndex entityIndex;
- CpEntityIndexDeleteListener esEntityIndexDeleteListener;
- SerializationFig serializationFig;
- private EntityIndexFactory eif;
-
- @Before
- public void setup(){
- this.entityIndex = mock(EntityIndex.class);
- serializationFig = mock(SerializationFig.class);
- this.eif = mock(EntityIndexFactory.class);
-
- this.esEntityIndexDeleteListener = new CpEntityIndexDeleteListener(eif, serializationFig);
- }
-
- @Test
- public void delete(){
- CollectionScope scope = mock(CollectionScope.class);
- UUID uuid = TimeUUIDUtils.getTimeUUID(10000L);
- Id entityId = new SimpleId(uuid,"test");
- CandidateResult entity = mock(CandidateResult.class);
- when(entity.getVersion()).thenReturn(uuid);
- when(entity.getId()).thenReturn(entityId);
- when(scope.getOwner()).thenReturn(entityId);
- when(scope.getName()).thenReturn("test");
- when(scope.getApplication()).thenReturn(entityId);
- when(eif.createEntityIndex(any(ApplicationScope.class))).thenReturn(entityIndex);
-
- final EntityIndexBatch batch = mock(EntityIndexBatch.class);
-
- when(entityIndex.createBatch()).thenReturn( batch );
-
- CandidateResults results = mock(CandidateResults.class);
- List<CandidateResult> resultsList = new ArrayList<>();
- resultsList.add(entity);
- Iterator<CandidateResult> entities = resultsList.iterator();
-
- when(results.iterator()).thenReturn(entities);
- when(serializationFig.getBufferSize()).thenReturn(10);
- when(serializationFig.getHistorySize()).thenReturn(20);
- when(entityIndex.getEntityVersions(any(IndexScope.class), entityId)).thenReturn(results);
- MvccEntity mvccEntity = new MvccEntityImpl(entityId,uuid, MvccEntity.Status.COMPLETE,mock(Entity.class));
-
-
- MvccEntityDeleteEvent event = new MvccEntityDeleteEvent(scope,uuid,mvccEntity);
- Observable<EntityVersion> o = esEntityIndexDeleteListener.receive(event);
- EntityVersion testEntity = o.toBlocking().last();
- assertEquals(testEntity.getId(),mvccEntity.getId());
-
- verify(entityIndex).createBatch();
-
- verify(batch).deindex(any(IndexScope.class), entity.getId(),entity.getVersion());
- }
-}