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/03/11 16:20:47 UTC
[07/10] git commit: Operation specific exception types.
Operation specific exception types.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e072f0bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e072f0bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e072f0bd
Branch: refs/pull/52/head
Commit: e072f0bdb7d58f37a17add88ba00f147a6e95a17
Parents: 717200b
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Mar 11 10:20:40 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Mar 11 10:20:40 2014 -0400
----------------------------------------------------------------------
.../exception/WriteCommitException.java | 44 ++++++++++++++++++++
.../WriteOptimisticVerifyException.java | 44 ++++++++++++++++++++
.../exception/WriteStartException.java | 44 ++++++++++++++++++++
.../exception/WriteUniqueVerifyException.java | 44 ++++++++++++++++++++
.../mvcc/stage/write/WriteCommit.java | 9 ++--
.../mvcc/stage/write/WriteOptimisticVerify.java | 6 +--
.../collection/mvcc/stage/write/WriteStart.java | 11 ++---
.../mvcc/stage/write/WriteUniqueVerify.java | 18 ++++----
8 files changed, 198 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e072f0bd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteCommitException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteCommitException.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteCommitException.java
new file mode 100644
index 0000000..14c1615
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteCommitException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.exception;
+
+public class WriteCommitException extends CollectionRuntimeException {
+ public WriteCommitException() {
+ }
+
+
+ public WriteCommitException( final String message ) {
+ super( message );
+ }
+
+
+ public WriteCommitException( final String message, final Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public WriteCommitException( final Throwable cause ) {
+ super( cause );
+ }
+
+
+ public WriteCommitException( final String message, final Throwable cause, final boolean enableSuppression,
+ final boolean writableStackTrace ) {
+ super( message, cause, enableSuppression, writableStackTrace );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e072f0bd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteOptimisticVerifyException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteOptimisticVerifyException.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteOptimisticVerifyException.java
new file mode 100644
index 0000000..b8b8f4f
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteOptimisticVerifyException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.exception;
+
+public class WriteOptimisticVerifyException extends CollectionRuntimeException {
+ public WriteOptimisticVerifyException() {
+ }
+
+
+ public WriteOptimisticVerifyException( final String message ) {
+ super( message );
+ }
+
+
+ public WriteOptimisticVerifyException( final String message, final Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public WriteOptimisticVerifyException( final Throwable cause ) {
+ super( cause );
+ }
+
+
+ public WriteOptimisticVerifyException( final String message, final Throwable cause, final boolean enableSuppression,
+ final boolean writableStackTrace ) {
+ super( message, cause, enableSuppression, writableStackTrace );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e072f0bd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteStartException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteStartException.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteStartException.java
new file mode 100644
index 0000000..a4a5f9e
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteStartException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.exception;
+
+public class WriteStartException extends CollectionRuntimeException {
+ public WriteStartException() {
+ }
+
+
+ public WriteStartException( final String message ) {
+ super( message );
+ }
+
+
+ public WriteStartException( final String message, final Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public WriteStartException( final Throwable cause ) {
+ super( cause );
+ }
+
+
+ public WriteStartException( final String message, final Throwable cause, final boolean enableSuppression,
+ final boolean writableStackTrace ) {
+ super( message, cause, enableSuppression, writableStackTrace );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e072f0bd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteUniqueVerifyException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteUniqueVerifyException.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteUniqueVerifyException.java
new file mode 100644
index 0000000..a003b16
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/WriteUniqueVerifyException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.exception;
+
+public class WriteUniqueVerifyException extends CollectionRuntimeException {
+ public WriteUniqueVerifyException() {
+ }
+
+
+ public WriteUniqueVerifyException( final String message ) {
+ super( message );
+ }
+
+
+ public WriteUniqueVerifyException( final String message, final Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public WriteUniqueVerifyException( final Throwable cause ) {
+ super( cause );
+ }
+
+
+ public WriteUniqueVerifyException( final String message, final Throwable cause, final boolean enableSuppression,
+ final boolean writableStackTrace ) {
+ super( message, cause, enableSuppression, writableStackTrace );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e072f0bd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java
index f274241..32bc540 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java
@@ -23,7 +23,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
import org.apache.usergrid.persistence.collection.mvcc.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
@@ -39,6 +38,7 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.netflix.astyanax.MutationBatch;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import org.apache.usergrid.persistence.collection.exception.WriteCommitException;
import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
import org.apache.usergrid.persistence.model.field.Field;
@@ -46,7 +46,8 @@ import rx.util.functions.Func1;
/**
- * This phase should invoke any finalization, and mark the entity as committed in the data store before returning
+ * This phase should invoke any finalization, and mark the entity as committed in the
+ * data store before returning
*/
@Singleton
public class WriteCommit implements Func1<CollectionIoEvent<MvccEntity>, Entity> {
@@ -68,7 +69,7 @@ public class WriteCommit implements Func1<CollectionIoEvent<MvccEntity>, Entity>
Preconditions.checkNotNull( logStrat, "MvccLogEntrySerializationStrategy is required" );
Preconditions.checkNotNull( entryStrat, "MvccEntitySerializationStrategy is required" );
- Preconditions.checkNotNull( uniqueValueStrat, "UniqueValueSerializationStrategy is required" );
+ Preconditions.checkNotNull( uniqueValueStrat, "UniqueValueSerializationStrategy is required");
this.logEntryStrat = logStrat;
this.entityStrat = entryStrat;
@@ -118,7 +119,7 @@ public class WriteCommit implements Func1<CollectionIoEvent<MvccEntity>, Entity>
}
catch ( ConnectionException e ) {
LOG.error( "Failed to execute write asynchronously ", e );
- throw new CollectionRuntimeException( "Failed to execute write asynchronously ", e );
+ throw new WriteCommitException( "Failed to execute write asynchronously ", e );
}
return entity.getEntity().get();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e072f0bd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerify.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerify.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerify.java
index be37d72..3196404 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerify.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerify.java
@@ -23,7 +23,7 @@ import com.google.inject.Singleton;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import java.util.List;
import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
+import org.apache.usergrid.persistence.collection.exception.WriteOptimisticVerifyException;
import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
@@ -78,13 +78,13 @@ public class WriteOptimisticVerify
final MvccLogEntry rollbackEntry =
new MvccLogEntryImpl( entity.getId(), entity.getVersion(), Stage.ROLLBACK);
logEntryStrat.write( collectionScope, rollbackEntry );
- throw new CollectionRuntimeException("Change conflict, not first writer");
+ throw new WriteOptimisticVerifyException("Change conflict, not first writer");
}
} catch ( ConnectionException e ) {
LOG.error( "Error reading entity log", e );
- throw new CollectionRuntimeException( "Error reading entity log", e );
+ throw new WriteOptimisticVerifyException( "Error reading entity log", e );
}
// No op, just emit the value
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e072f0bd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStart.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStart.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStart.java
index 01fee57..c603f57 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStart.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStart.java
@@ -7,7 +7,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
@@ -23,13 +22,14 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.netflix.astyanax.MutationBatch;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import org.apache.usergrid.persistence.collection.exception.WriteStartException;
import rx.util.functions.Func1;
/**
- * This is the first stage and should be invoked immediately when a write is started. It should persist the start of a
- * new write in the data store for a checkpoint and recovery
+ * This is the first stage and should be invoked immediately when a write is started. It should
+ * persist the start of a new write in the data store for a checkpoint and recovery
*/
@Singleton
public class WriteStart implements Func1<CollectionIoEvent<Entity>, CollectionIoEvent<MvccEntity>> {
@@ -73,13 +73,14 @@ public class WriteStart implements Func1<CollectionIoEvent<Entity>, CollectionIo
}
catch ( ConnectionException e ) {
LOG.error( "Failed to execute write ", e );
- throw new CollectionRuntimeException( "Failed to execute write ", e );
+ throw new WriteStartException( "Failed to execute write ", e );
}
//create the mvcc entity for the next stage
//todo, we need to create a complete or partial update here (or sooner)
- final MvccEntityImpl nextStage = new MvccEntityImpl( entityId, version, MvccEntity.Status.COMPLETE, entity );
+ final MvccEntityImpl nextStage =
+ new MvccEntityImpl( entityId, version, MvccEntity.Status.COMPLETE, entity );
return new CollectionIoEvent<MvccEntity>( collectionScope, nextStage );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e072f0bd/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
index 55280c8..02ed9db 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
@@ -24,7 +24,6 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
@@ -37,6 +36,7 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.netflix.astyanax.MutationBatch;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
import rx.Observable;
import rx.Scheduler;
@@ -101,7 +101,8 @@ public class WriteUniqueVerify implements Func1<CollectionIoEvent<MvccEntity>, O
//if it's unique, create a function to validate it and add it to the list of concurrent validations
if ( field.isUnique() ) {
- Observable<FieldUniquenessResult> result = Observable.from( field ).subscribeOn( scheduler ).map(new Func1<Field, FieldUniquenessResult>() {
+ Observable<FieldUniquenessResult> result =
+ Observable.from( field ).subscribeOn( scheduler ).map(new Func1<Field, FieldUniquenessResult>() {
@Override
public FieldUniquenessResult call(Field field ) {
@@ -116,8 +117,8 @@ public class WriteUniqueVerify implements Func1<CollectionIoEvent<MvccEntity>, O
mb.execute();
}
catch ( ConnectionException ex ) {
- throw new CollectionRuntimeException( "Error writing unique value " + field.toString(),
- ex );
+ throw new WriteUniqueVerifyException(
+ "Error writing unique value " + field.toString(), ex );
}
// does the database value match what we wrote?
@@ -126,7 +127,7 @@ public class WriteUniqueVerify implements Func1<CollectionIoEvent<MvccEntity>, O
loaded = uniqueValueStrat.load( ioevent.getEntityCollection(), field );
}
catch ( ConnectionException ex ) {
- throw new CollectionRuntimeException( ex );
+ throw new WriteUniqueVerifyException( "Error verifying write", ex );
}
return new FieldUniquenessResult( field, loaded.equals( written ) );
@@ -149,16 +150,14 @@ public class WriteUniqueVerify implements Func1<CollectionIoEvent<MvccEntity>, O
@Override
public CollectionIoEvent<MvccEntity> call( final Object... args ) {
-
-
for ( Object resultObj : args ) {
FieldUniquenessResult result = ( FieldUniquenessResult ) resultObj;
if ( !result.isUnique() ) {
Field field = result.getField();
- throw new CollectionRuntimeException(
- "Duplicate field value " + field.getName() + " = " + field.getValue().toString() );
+ throw new WriteUniqueVerifyException(
+ "Duplicate field value " + field.getName() + " = " + field.getValue().toString() );
}
}
@@ -167,7 +166,6 @@ public class WriteUniqueVerify implements Func1<CollectionIoEvent<MvccEntity>, O
}
};
-
return Observable.zip( fields, zipFunction );
}