diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2006-08-30 01:48:56 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2006-08-30 01:48:56 +0000 |
commit | 59bf9d28054da49fc2e984fce43a7840ddee5424 (patch) | |
tree | 9669615406a6c9c85f0a5e649dd74e6569c6e408 /src | |
parent | 3635740f2fcb24192cfa20a3d8d30cbc690c64d8 (diff) |
Added common capabilities
Diffstat (limited to 'src')
7 files changed, 312 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/capability/Capability.java b/src/main/java/com/amazon/carbonado/capability/Capability.java new file mode 100644 index 0000000..5c0871a --- /dev/null +++ b/src/main/java/com/amazon/carbonado/capability/Capability.java @@ -0,0 +1,28 @@ +/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed 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 com.amazon.carbonado.capability;
+
+/**
+ * Marker interface for identifying extra repository capabilities.
+ *
+ * @author Brian S O'Neill
+ * @see com.amazon.carbonado.Repository#getCapability
+ */
+public interface Capability {
+}
diff --git a/src/main/java/com/amazon/carbonado/capability/IndexInfo.java b/src/main/java/com/amazon/carbonado/capability/IndexInfo.java new file mode 100644 index 0000000..5cd6298 --- /dev/null +++ b/src/main/java/com/amazon/carbonado/capability/IndexInfo.java @@ -0,0 +1,61 @@ +/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed 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 com.amazon.carbonado.capability;
+
+import com.amazon.carbonado.info.Direction;
+
+/**
+ * General information about an index defined in a {@link com.amazon.carbonado.Storage}.
+ *
+ * <p>IndexInfo instances are thread-safe and immutable.
+ *
+ * @author Brian S O'Neill
+ * @see IndexInfoCapability
+ */
+public interface IndexInfo {
+ /**
+ * Returns the name of this index, or null if not applicable.
+ */
+ String getName();
+
+ /**
+ * Returns true if index entries are unique.
+ */
+ boolean isUnique();
+
+ /**
+ * Returns true if index is clustered, which means it defines the physical
+ * ordering of storables.
+ */
+ boolean isClustered();
+
+ /**
+ * Returns the properties in this index. The array might be empty, but it
+ * is never null. The array is a copy, and so it may be safely modified.
+ */
+ String[] getPropertyNames();
+
+ /**
+ * Returns the directions of all the properties in this index. The length
+ * of the array matches the length returned by {@link
+ * #getPropertyNames}. The array is a copy, and so it may be safely
+ * modified.
+ */
+ Direction[] getPropertyDirections();
+}
diff --git a/src/main/java/com/amazon/carbonado/capability/IndexInfoCapability.java b/src/main/java/com/amazon/carbonado/capability/IndexInfoCapability.java new file mode 100644 index 0000000..023bc53 --- /dev/null +++ b/src/main/java/com/amazon/carbonado/capability/IndexInfoCapability.java @@ -0,0 +1,37 @@ +/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed 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 com.amazon.carbonado.capability;
+
+import com.amazon.carbonado.RepositoryException;
+import com.amazon.carbonado.Storable;
+
+/**
+ * Capability for getting information about physical indexes for storables.
+ *
+ * @author Brian S O'Neill
+ */
+public interface IndexInfoCapability extends Capability {
+ /**
+ * Returns information about the known indexes for the given storable
+ * type. The array might be empty, but it is never null. The array is a
+ * copy, and so it may be safely modified.
+ */
+ <S extends Storable> IndexInfo[] getIndexInfo(Class<S> storableType)
+ throws RepositoryException;
+}
diff --git a/src/main/java/com/amazon/carbonado/capability/ResyncCapability.java b/src/main/java/com/amazon/carbonado/capability/ResyncCapability.java new file mode 100644 index 0000000..d3e7c82 --- /dev/null +++ b/src/main/java/com/amazon/carbonado/capability/ResyncCapability.java @@ -0,0 +1,46 @@ +/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed 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 com.amazon.carbonado.capability;
+
+import com.amazon.carbonado.RepositoryException;
+import com.amazon.carbonado.Storable;
+
+/**
+ * Capability of replicating repositories for re-synchronizing to the master
+ * repository. A re-sync operation can be used to fill up a fresh replication
+ * repository or to repair inconsistencies.
+ *
+ * @author Brian S O'Neill
+ */
+public interface ResyncCapability extends Capability {
+ /**
+ * Re-synchronizes replicated storables against the master repository.
+ *
+ * @param type type of storable to re-sync
+ * @param desiredSpeed throttling parameter - 1.0 = full speed, 0.5 = half
+ * speed, 0.1 = one-tenth speed, etc
+ * @param filter optional query filter to limit which objects get re-sync'ed
+ * @param filterValues filter values for optional filter
+ */
+ <S extends Storable> void resync(Class<S> type,
+ double desiredSpeed,
+ String filter,
+ Object... filterValues)
+ throws RepositoryException;
+}
diff --git a/src/main/java/com/amazon/carbonado/capability/ShutdownCapability.java b/src/main/java/com/amazon/carbonado/capability/ShutdownCapability.java new file mode 100644 index 0000000..4940757 --- /dev/null +++ b/src/main/java/com/amazon/carbonado/capability/ShutdownCapability.java @@ -0,0 +1,61 @@ +/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed 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 com.amazon.carbonado.capability;
+
+/**
+ * Capability for repositories that require special attention with the Java
+ * virtual machine exits.
+ *
+ * @author Brian S O'Neill
+ */
+public interface ShutdownCapability extends Capability {
+ /**
+ * Returns true if repository has a shutdown hook registered to
+ * automatically call shutdown when the virtual machine exits.
+ */
+ boolean isAutoShutdownEnabled();
+
+ /**
+ * Request to enable or disable the automatic shutdown hook. Repository may
+ * ignore this request.
+ *
+ * @throws SecurityException if caller does not have permission
+ */
+ void setAutoShutdownEnabled(boolean enabled);
+
+ /**
+ * Similar to calling close on a repository, except should only be called
+ * when the virtual machine is in the process of shutting down. Calling
+ * close may cause spurious exceptions to be thrown by other threads which
+ * may be interacting with the repository. Shutdown tries to reduce these
+ * exceptions from being thrown by effectively <i>suspending</i> any
+ * threads which continue to interact with this repository. <b>For this
+ * reason, this method should only ever be called during a virtual machine
+ * shutdown.</b>
+ *
+ * <p>Repositories may choose to implement this method by simply calling
+ * close. There is no guarantee that shutdown will reduce exceptions, and
+ * it might not suspend any threads. Also, repositories that require proper
+ * shutdown should automatically register runtime hooks, and so this method
+ * usually doesn't need to be called manually.
+ *
+ * @throws SecurityException if caller does not have permission
+ */
+ void shutdown();
+}
diff --git a/src/main/java/com/amazon/carbonado/capability/StorableInfoCapability.java b/src/main/java/com/amazon/carbonado/capability/StorableInfoCapability.java new file mode 100644 index 0000000..763fede --- /dev/null +++ b/src/main/java/com/amazon/carbonado/capability/StorableInfoCapability.java @@ -0,0 +1,55 @@ +/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed 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 com.amazon.carbonado.capability;
+
+import com.amazon.carbonado.RepositoryException;
+import com.amazon.carbonado.Storable;
+
+/**
+ * Capability that returns information about known storable types in a
+ * repository.
+ *
+ * @author Brian S O'Neill
+ */
+public interface StorableInfoCapability extends Capability {
+ /**
+ * Returns an array of storable type class names for user-level storables
+ * known to the repository. The array might be empty, but it is never
+ * null. The array is a copy, and so it may be safely modified.
+ * <p>
+ * This method returns class names instead of class instances because the
+ * repository may not be able to load the classes.
+ */
+ String[] getUserStorableTypeNames() throws RepositoryException;
+
+ /**
+ * Returns true if the given storable type is supported.
+ *
+ * @param type storable type to examine
+ */
+ boolean isSupported(Class<Storable> type);
+
+ /**
+ * Returns true if the given property exists and is supported.
+ *
+ * @param type storable type to examine
+ * @param name name of property to examine
+ */
+ boolean isPropertySupported(Class<Storable> type, String name);
+}
diff --git a/src/main/java/com/amazon/carbonado/capability/package-info.java b/src/main/java/com/amazon/carbonado/capability/package-info.java new file mode 100644 index 0000000..7d3cdca --- /dev/null +++ b/src/main/java/com/amazon/carbonado/capability/package-info.java @@ -0,0 +1,24 @@ +/*
+ * Copyright 2006 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Common capabilities for repositories.
+ *
+ * @see com.amazon.carbonado.Repository#getCapability
+ */
+package com.amazon.carbonado.capability;
|