diff options
Diffstat (limited to 'src/main/java/com/amazon/carbonado')
10 files changed, 34 insertions, 21 deletions
diff --git a/src/main/java/com/amazon/carbonado/RepositoryBuilder.java b/src/main/java/com/amazon/carbonado/RepositoryBuilder.java index 4b1d3fe..179d902 100644 --- a/src/main/java/com/amazon/carbonado/RepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/RepositoryBuilder.java @@ -57,7 +57,7 @@ public interface RepositoryBuilder { * @throws ConfigurationException if there is a problem in the builder's configuration
* @throws RepositoryException if there is a general problem opening the repository
*/
- Repository build(RepositoryReference rootReference)
+ Repository build(AtomicReference<Repository> rootReference)
throws ConfigurationException, RepositoryException;
/**
@@ -99,6 +99,4 @@ public interface RepositoryBuilder { * @see com.amazon.carbonado.repo.replicated.ReplicatedRepositoryBuilder
*/
void setMaster(boolean b);
-
- public class RepositoryReference extends AtomicReference<Repository> {}
}
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java index 4d6e371..59a359b 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java @@ -23,11 +23,12 @@ import java.util.Arrays; import java.util.Map;
import java.util.IdentityHashMap;
+import java.util.concurrent.atomic.AtomicReference;
+
import com.amazon.carbonado.Cursor;
import com.amazon.carbonado.IsolationLevel;
import com.amazon.carbonado.MalformedTypeException;
import com.amazon.carbonado.Repository;
-import static com.amazon.carbonado.RepositoryBuilder.RepositoryReference;
import com.amazon.carbonado.RepositoryException;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.Storage;
@@ -56,12 +57,12 @@ class IndexedRepository implements Repository, StorableInfoCapability,
IndexEntryAccessCapability
{
- private final RepositoryReference mRootRef;
+ private final AtomicReference<Repository> mRootRef;
private final Repository mRepository;
private final String mName;
private final Map<Class<?>, IndexedStorage<?>> mStorages;
- IndexedRepository(RepositoryReference rootRef, String name, Repository repository) {
+ IndexedRepository(AtomicReference<Repository> rootRef, String name, Repository repository) {
mRootRef = rootRef;
mRepository = repository;
mName = name;
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepositoryBuilder.java index f3ec04b..a1aa45e 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepositoryBuilder.java @@ -20,6 +20,8 @@ package com.amazon.carbonado.repo.indexed; import java.util.Collection;
+import java.util.concurrent.atomic.AtomicReference;
+
import com.amazon.carbonado.ConfigurationException;
import com.amazon.carbonado.Repository;
import com.amazon.carbonado.RepositoryBuilder;
@@ -48,7 +50,7 @@ public class IndexedRepositoryBuilder extends AbstractRepositoryBuilder { public IndexedRepositoryBuilder() {
}
- public Repository build(RepositoryReference rootRef) throws RepositoryException {
+ public Repository build(AtomicReference<Repository> rootRef) throws RepositoryException {
assertReady();
Repository wrapped;
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java index 97be915..bcdd0c4 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepository.java @@ -24,6 +24,8 @@ import java.sql.SQLException; import java.util.Map;
import java.util.IdentityHashMap;
+import java.util.concurrent.atomic.AtomicReference;
+
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
@@ -39,7 +41,6 @@ import com.amazon.carbonado.SupportException; import com.amazon.carbonado.MalformedTypeException;
import com.amazon.carbonado.PersistException;
import com.amazon.carbonado.Repository;
-import static com.amazon.carbonado.RepositoryBuilder.RepositoryReference;
import com.amazon.carbonado.RepositoryException;
import com.amazon.carbonado.Transaction;
import com.amazon.carbonado.UnsupportedTypeException;
@@ -134,7 +135,7 @@ public class JDBCRepository private final String mName;
final boolean mIsMaster;
- private final RepositoryReference mRootRef;
+ private final AtomicReference<Repository> mRootRef;
private final String mDatabaseProductName;
private final DataSource mDataSource;
private final String mCatalog;
@@ -176,7 +177,7 @@ public class JDBCRepository * database independent
*/
@SuppressWarnings("unchecked")
- JDBCRepository(RepositoryReference rootRef,
+ JDBCRepository(AtomicReference<Repository> rootRef,
String name, boolean isMaster,
DataSource dataSource, String catalog, String schema)
throws RepositoryException
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java index 507d70a..3a797e8 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCRepositoryBuilder.java @@ -21,9 +21,12 @@ package com.amazon.carbonado.repo.jdbc; import java.sql.SQLException;
import java.util.Collection;
+import java.util.concurrent.atomic.AtomicReference;
+
import javax.sql.DataSource;
import com.amazon.carbonado.ConfigurationException;
+import com.amazon.carbonado.Repository;
import com.amazon.carbonado.RepositoryException;
import com.amazon.carbonado.spi.AbstractRepositoryBuilder;
@@ -66,7 +69,7 @@ public class JDBCRepositoryBuilder extends AbstractRepositoryBuilder { public JDBCRepositoryBuilder() {
}
- public JDBCRepository build(RepositoryReference rootRef) throws RepositoryException {
+ public JDBCRepository build(AtomicReference<Repository> rootRef) throws RepositoryException {
assertReady();
JDBCRepository repo = new JDBCRepository
(rootRef, getName(), isMaster(), getDataSource(), mCatalog, mSchema);
diff --git a/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java b/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java index e44e3b7..3f17d17 100644 --- a/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepository.java @@ -21,9 +21,10 @@ package com.amazon.carbonado.repo.logging; import java.util.IdentityHashMap;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
import com.amazon.carbonado.IsolationLevel;
import com.amazon.carbonado.Repository;
-import static com.amazon.carbonado.RepositoryBuilder.RepositoryReference;
import com.amazon.carbonado.RepositoryException;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.Storage;
@@ -38,14 +39,14 @@ import com.amazon.carbonado.capability.Capability; * @author Brian S O'Neill
*/
class LoggingRepository implements Repository, LogAccessCapability {
- private final RepositoryReference mRootRef;
+ private final AtomicReference<Repository> mRootRef;
private final Repository mRepo;
private final Log mLog;
// Map of storages by storable class
private final Map<Class<?>, LoggingStorage<?>> mStorages;
- LoggingRepository(RepositoryReference rootRef, Repository actual, Log log) {
+ LoggingRepository(AtomicReference<Repository> rootRef, Repository actual, Log log) {
mRootRef = rootRef;
mRepo = actual;
mLog = log;
diff --git a/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepositoryBuilder.java index 5f06cd5..956c947 100644 --- a/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/repo/logging/LoggingRepositoryBuilder.java @@ -20,6 +20,8 @@ package com.amazon.carbonado.repo.logging; import java.util.Collection;
+import java.util.concurrent.atomic.AtomicReference;
+
import com.amazon.carbonado.ConfigurationException;
import com.amazon.carbonado.Repository;
import com.amazon.carbonado.RepositoryBuilder;
@@ -56,7 +58,7 @@ public class LoggingRepositoryBuilder extends AbstractRepositoryBuilder { public LoggingRepositoryBuilder() {
}
- public Repository build(RepositoryReference rootRef) throws RepositoryException {
+ public Repository build(AtomicReference<Repository> rootRef) throws RepositoryException {
if (mName == null) {
if (mRepoBuilder != null) {
mName = mRepoBuilder.getName();
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java index 8d5cc75..2a09c19 100644 --- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepositoryBuilder.java @@ -19,6 +19,8 @@ package com.amazon.carbonado.repo.replicated; import java.util.Collection;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -53,7 +55,7 @@ public class ReplicatedRepositoryBuilder extends AbstractRepositoryBuilder { public ReplicatedRepositoryBuilder() {
}
- public Repository build(RepositoryReference rootRef) throws RepositoryException {
+ public Repository build(AtomicReference<Repository> rootRef) throws RepositoryException {
assertReady();
Repository replica, master;
diff --git a/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java index 902d516..a8f0169 100644 --- a/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java @@ -21,6 +21,8 @@ package com.amazon.carbonado.spi; import java.util.ArrayList;
import java.util.Collection;
+import java.util.concurrent.atomic.AtomicReference;
+
import com.amazon.carbonado.ConfigurationException;
import com.amazon.carbonado.Repository;
import com.amazon.carbonado.RepositoryBuilder;
@@ -37,7 +39,7 @@ public abstract class AbstractRepositoryBuilder implements RepositoryBuilder { }
public Repository build() throws ConfigurationException, RepositoryException {
- return build(new RepositoryReference());
+ return build(new AtomicReference<Repository>());
}
/**
diff --git a/src/main/java/com/amazon/carbonado/spi/BelatedRepositoryCreator.java b/src/main/java/com/amazon/carbonado/spi/BelatedRepositoryCreator.java index 9674560..f0ad404 100644 --- a/src/main/java/com/amazon/carbonado/spi/BelatedRepositoryCreator.java +++ b/src/main/java/com/amazon/carbonado/spi/BelatedRepositoryCreator.java @@ -18,12 +18,13 @@ package com.amazon.carbonado.spi;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.apache.commons.logging.Log;
import com.amazon.carbonado.IsolationLevel;
import com.amazon.carbonado.Repository;
import com.amazon.carbonado.RepositoryBuilder;
-import static com.amazon.carbonado.RepositoryBuilder.RepositoryReference;
import com.amazon.carbonado.RepositoryException;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.Storage;
@@ -47,7 +48,7 @@ import com.amazon.carbonado.util.BelatedCreator; public class BelatedRepositoryCreator extends BelatedCreator<Repository, SupportException> {
final Log mLog;
final RepositoryBuilder mBuilder;
- final RepositoryReference mRootRef;
+ final AtomicReference<Repository> mRootRef;
/**
* @param log error reporting log
@@ -56,7 +57,7 @@ public class BelatedRepositoryCreator extends BelatedCreator<Repository, Support * to create object after failure; if negative, never retry
*/
public BelatedRepositoryCreator(Log log, RepositoryBuilder builder, int minRetryDelayMillis) {
- this(log, builder, new RepositoryReference(), minRetryDelayMillis);
+ this(log, builder, new AtomicReference<Repository>(), minRetryDelayMillis);
}
/**
@@ -68,7 +69,7 @@ public class BelatedRepositoryCreator extends BelatedCreator<Repository, Support */
public BelatedRepositoryCreator(Log log,
RepositoryBuilder builder,
- RepositoryReference rootRef,
+ AtomicReference<Repository> rootRef,
int minRetryDelayMillis)
{
super(Repository.class, minRetryDelayMillis);
|