http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryTypeMetadata.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryTypeMetadata.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryTypeMetadata.java new file mode 100644 index 0000000..cf42014 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryTypeMetadata.java @@ -0,0 +1,196 @@ +/* + * 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.ignite.cache.query; + +import org.apache.ignite.lang.*; +import org.gridgain.grid.util.tostring.*; +import org.gridgain.grid.util.typedef.internal.*; + +import java.util.*; + +/** + * Cache query type metadata. + */ +public class GridCacheQueryTypeMetadata { + /** Type name, e.g. class name. */ + @GridToStringInclude + private String type; + + /** Fields to be queried, in addition to indexed fields. */ + @GridToStringInclude + private Map<String, Class<?>> qryFlds = new HashMap<>(); + + /** Fields to index in ascending order. */ + @GridToStringInclude + private Map<String, Class<?>> ascFlds = new HashMap<>(); + + /** Fields to index in descending order. */ + @GridToStringInclude + private Map<String, Class<?>> descFlds = new HashMap<>(); + + /** Fields to index as text. */ + @GridToStringInclude + private Collection<String> txtFlds = new LinkedHashSet<>(); + + /** Fields to create group indexes for. */ + @GridToStringInclude + private Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps; + + /** + * Default constructor. + */ + public GridCacheQueryTypeMetadata() { + // No-op. + } + + /** + * + */ + public GridCacheQueryTypeMetadata(GridCacheQueryTypeMetadata src) { + type = src.getType(); + + qryFlds = new HashMap<>(src.getQueryFields()); + ascFlds = new HashMap<>(src.getAscendingFields()); + descFlds = new HashMap<>(src.getDescendingFields()); + txtFlds = new HashSet<>(src.getTextFields()); + + grps = new HashMap<>(src.getGroups()); + } + + /** + * Gets type (e.g. class name). + * + * @return Type name. + */ + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param cls Type class. + */ + public void setType(Class<?> cls) { + setType(cls.getName()); + } + + /** + * Sets type. + * + * @param type Type name. + */ + public void setType(String type) { + this.type = type; + } + + /** + * Gets query-enabled fields. + * + * @return Collection of fields available for query. + */ + public Map<String, Class<?>> getQueryFields() { + return qryFlds; + } + + /** + * Sets query fields map. + * + * @param qryFlds Query fields. + */ + public void setQueryFields(Map<String, Class<?>> qryFlds) { + this.qryFlds = qryFlds; + } + + /** + * Gets ascending-indexed fields. + * + * @return Map of ascending-indexed fields. + */ + public Map<String, Class<?>> getAscendingFields() { + return ascFlds; + } + + /** + * Sets ascending-indexed fields. + * + * @param ascFlds Map of ascending-indexed fields. + */ + public void setAscendingFields(Map<String, Class<?>> ascFlds) { + this.ascFlds = ascFlds; + } + + /** + * Gets descending-indexed fields. + * + * @return Map of descending-indexed fields. + */ + public Map<String, Class<?>> getDescendingFields() { + return descFlds; + } + + /** + * Sets descending-indexed fields. + * + * @param descFlds Map of descending-indexed fields. + */ + public void setDescendingFields(Map<String, Class<?>> descFlds) { + this.descFlds = descFlds; + } + + /** + * Gets text-indexed fields. + * + * @return Collection of text indexed fields. + */ + public Collection<String> getTextFields() { + return txtFlds; + } + + /** + * Sets text-indexed fields. + * + * @param txtFlds Text-indexed fields. + */ + public void setTextFields(Collection<String> txtFlds) { + this.txtFlds = txtFlds; + } + + /** + * Gets group-indexed fields. + * + * @return Map of group-indexed fields. + */ + public Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> getGroups() { + return grps; + } + + /** + * Sets group-indexed fields. + * + * @param grps Map of group-indexed fields from index name to index fields. + */ + public void setGroups(Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps) { + this.grps = grps; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridCacheQueryTypeMetadata.class, this); + } +}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryTypeResolver.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryTypeResolver.java b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryTypeResolver.java new file mode 100644 index 0000000..0987350 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/GridCacheQueryTypeResolver.java @@ -0,0 +1,32 @@ +/* + * 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.ignite.cache.query; + +/** + * Interface allowing to override table name for portable objects stored in cache. + */ +public interface GridCacheQueryTypeResolver { + /** + * Allows to override type name for portable objects being stored in cache. + * + * @param key Key. + * @param val Value. + * @return Type name. + */ + public String resolveTypeName(Object key, Object val); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java index 6aee153..7a2b0f0 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java @@ -28,8 +28,8 @@ import javax.cache.event.*; * Continuous queries are executed as follows: * <ol> * <li> - * Query is sent to requested grid nodes. Note that for {@link org.gridgain.grid.cache.GridCacheMode#LOCAL LOCAL} - * and {@link org.gridgain.grid.cache.GridCacheMode#REPLICATED REPLICATED} caches query will be always executed + * Query is sent to requested grid nodes. Note that for {@link org.apache.ignite.cache.GridCacheMode#LOCAL LOCAL} + * and {@link org.apache.ignite.cache.GridCacheMode#REPLICATED REPLICATED} caches query will be always executed * locally. * </li> * <li> @@ -104,7 +104,7 @@ import javax.cache.event.*; * qry.cancel(); * </pre> * Note that one query instance can be executed only once. After it's cancelled, it's non-operational. - * If you need to repeat execution, use {@link org.gridgain.grid.cache.query.GridCacheQueries#createContinuousQuery()} method to create + * If you need to repeat execution, use {@link org.apache.ignite.cache.query.GridCacheQueries#createContinuousQuery()} method to create * new query. */ // TODO: make class. @@ -197,7 +197,7 @@ public final class QueryContinuousPredicate<K, V> extends QueryPredicate<K, V> i /** * Stops continuous query execution. <p> Note that one query instance can be executed only once. After it's * cancelled, it's non-operational. If you need to repeat execution, use {@link - * org.gridgain.grid.cache.query.GridCacheQueries#createContinuousQuery()} method to create new query. + * org.apache.ignite.cache.query.GridCacheQueries#createContinuousQuery()} method to create new query. * * @throws IgniteCheckedException In case of error. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java index a6d0587..8c28811 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java @@ -21,8 +21,8 @@ import java.lang.annotation.*; /** * Annotates fields for SQL queries. All fields that will be involved in SQL clauses must have - * this annotation. For more information about cache queries see {@link org.gridgain.grid.cache.query.GridCacheQuery} documentation. - * @see org.gridgain.grid.cache.query.GridCacheQuery + * this annotation. For more information about cache queries see {@link org.apache.ignite.cache.query.GridCacheQuery} documentation. + * @see org.apache.ignite.cache.query.GridCacheQuery */ @Documented @Retention(RetentionPolicy.RUNTIME) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java index c0db224..bac479d 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java @@ -22,8 +22,8 @@ import java.lang.annotation.*; /** * Annotation for fields or getters to be indexed for full text * search using {@code H2 TEXT} indexing. For more information - * refer to {@link org.gridgain.grid.cache.query.GridCacheQuery} documentation. - * @see org.gridgain.grid.cache.query.GridCacheQuery + * refer to {@link org.apache.ignite.cache.query.GridCacheQuery} documentation. + * @see org.apache.ignite.cache.query.GridCacheQuery */ @Documented @Retention(RetentionPolicy.RUNTIME) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/query/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/package.html b/modules/core/src/main/java/org/apache/ignite/cache/query/package.html new file mode 100644 index 0000000..40ade50 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/package.html @@ -0,0 +1,23 @@ +<!-- + 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. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<body> +<!-- Package description. --> +Contains APIs for creating and executing cache queries. +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java index ab928d5..de7b0fc 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java @@ -101,7 +101,7 @@ public abstract class CacheLoadOnlyStoreAdapter<K, V, I> extends CacheStore<K, V * Note that returned iterator doesn't have to be thread-safe. Thus it could * operate on raw streams, DB connections, etc. without additional synchronization. * - * @param args Arguments passes into {@link GridCache#loadCache(IgniteBiPredicate, long, Object...)} method. + * @param args Arguments passes into {@link org.apache.ignite.cache.GridCache#loadCache(IgniteBiPredicate, long, Object...)} method. * @return Iterator over input records. * @throws CacheLoaderException If iterator can't be created with the given arguments. */ @@ -114,7 +114,7 @@ public abstract class CacheLoadOnlyStoreAdapter<K, V, I> extends CacheStore<K, V * If {@code null} is returned then this record will be just skipped. * * @param rec A raw data record. - * @param args Arguments passed into {@link GridCache#loadCache(IgniteBiPredicate, long, Object...)} method. + * @param args Arguments passed into {@link org.apache.ignite.cache.GridCache#loadCache(IgniteBiPredicate, long, Object...)} method. * @return Cache entry to be saved in cache or {@code null} if no entry could be produced from this record. */ @Nullable protected abstract IgniteBiTuple<K, V> parse(I rec, @Nullable Object... args); @@ -276,7 +276,7 @@ public abstract class CacheLoadOnlyStoreAdapter<K, V, I> extends CacheStore<K, V /** * @param c Closure for loaded entries. * @param buf Set of input records to process. - * @param args Arguments passed into {@link GridCache#loadCache(IgniteBiPredicate, long, Object...)} method. + * @param args Arguments passed into {@link org.apache.ignite.cache.GridCache#loadCache(IgniteBiPredicate, long, Object...)} method. */ Worker(IgniteBiInClosure<K, V> c, Collection<I> buf, Object[] args) { this.c = c; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java index d2593ae..1c59641 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java @@ -133,7 +133,7 @@ public abstract class CacheStore<K, V> implements CacheLoader<K, V>, CacheWriter /** * Loads all values from underlying persistent storage. Note that keys are not * passed, so it is up to implementation to figure out what to load. This method - * is called whenever {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} + * is called whenever {@link org.apache.ignite.cache.GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} * method is invoked which is usually to preload the cache from persistent storage. * <p> * This method is optional, and cache implementation does not depend on this @@ -146,7 +146,7 @@ public abstract class CacheStore<K, V> implements CacheLoader<K, V>, CacheWriter * * @param clo Closure for loaded values. * @param args Arguments passes into - * {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method. + * {@link org.apache.ignite.cache.GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method. * @throws CacheLoaderException If loading failed. */ public abstract void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) throws CacheLoaderException; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java index 232cf9d..475cfba 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java @@ -40,7 +40,7 @@ import java.util.*; public abstract class CacheStoreAdapter<K, V> extends CacheStore<K, V> { /** * Default empty implementation. This method needs to be overridden only if - * {@link GridCache#loadCache(IgniteBiPredicate, long, Object...)} method + * {@link org.apache.ignite.cache.GridCache#loadCache(IgniteBiPredicate, long, Object...)} method * is explicitly called. * * @param clo {@inheritDoc} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/configuration/GridQueryConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/GridQueryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/GridQueryConfiguration.java index 7e5efd1..e791f19 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/GridQueryConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/GridQueryConfiguration.java @@ -17,7 +17,6 @@ package org.apache.ignite.configuration; -import org.gridgain.grid.cache.query.*; import org.gridgain.grid.util.typedef.internal.*; import org.jetbrains.annotations.*; @@ -124,7 +123,7 @@ public class GridQueryConfiguration { } /** - * Sets classes with methods annotated by {@link GridCacheQuerySqlFunction} + * Sets classes with methods annotated by {@link org.apache.ignite.cache.query.GridCacheQuerySqlFunction} * to be used as user-defined functions from SQL queries. * * @param idxCustomFuncClss List of classes. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryExecutedEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryExecutedEvent.java b/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryExecutedEvent.java index 9b7da71..5b327ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryExecutedEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryExecutedEvent.java @@ -17,9 +17,9 @@ package org.apache.ignite.events; +import org.apache.ignite.cache.query.*; import org.apache.ignite.cluster.*; import org.apache.ignite.lang.*; -import org.gridgain.grid.cache.query.*; import org.gridgain.grid.util.tostring.*; import org.gridgain.grid.util.typedef.internal.*; import org.jetbrains.annotations.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryReadEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryReadEvent.java b/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryReadEvent.java index 161ca0d..08ed78c 100644 --- a/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryReadEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/events/IgniteCacheQueryReadEvent.java @@ -17,9 +17,9 @@ package org.apache.ignite.events; +import org.apache.ignite.cache.query.*; import org.apache.ignite.cluster.*; import org.apache.ignite.lang.*; -import org.gridgain.grid.cache.query.*; import org.gridgain.grid.util.tostring.*; import org.gridgain.grid.util.typedef.internal.*; import org.jetbrains.annotations.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 44486d6..69d462a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -19,12 +19,12 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.*; import org.apache.ignite.cache.query.*; import org.apache.ignite.cluster.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; import org.gridgain.grid.cache.*; -import org.gridgain.grid.kernal.*; import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.util.tostring.*; import org.gridgain.grid.util.typedef.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/jdbc/GridJdbcDriver.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/jdbc/GridJdbcDriver.java b/modules/core/src/main/java/org/apache/ignite/jdbc/GridJdbcDriver.java index 2af8f1f..c13ecf6 100644 --- a/modules/core/src/main/java/org/apache/ignite/jdbc/GridJdbcDriver.java +++ b/modules/core/src/main/java/org/apache/ignite/jdbc/GridJdbcDriver.java @@ -49,7 +49,7 @@ import java.util.logging.*; * <li> * Joins will work correctly only if joined objects are stored in * collocated mode. Refer to - * {@link GridCacheAffinityKey} + * {@link org.apache.ignite.cache.affinity.GridCacheAffinityKey} * javadoc for more details. * </li> * <li> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/lang/IgnitePredicate.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgnitePredicate.java b/modules/core/src/main/java/org/apache/ignite/lang/IgnitePredicate.java index ef186c7..dc4660c 100644 --- a/modules/core/src/main/java/org/apache/ignite/lang/IgnitePredicate.java +++ b/modules/core/src/main/java/org/apache/ignite/lang/IgnitePredicate.java @@ -25,7 +25,7 @@ import java.io.*; * Defines a predicate which accepts a parameter and returns {@code true} or {@code false}. In * GridGain, predicates are generally used for filtering nodes within grid projections, or for * providing atomic filters when performing cache operation, like in - * {@link GridCache#put(Object, Object, IgnitePredicate[])} method. + * {@link org.apache.ignite.cache.GridCache#put(Object, Object, IgnitePredicate[])} method. * * @param <E> Type of predicate parameter. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/streamer/router/StreamerCacheAffinityEventRouter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/streamer/router/StreamerCacheAffinityEventRouter.java b/modules/core/src/main/java/org/apache/ignite/streamer/router/StreamerCacheAffinityEventRouter.java index b6de55d..df02346 100644 --- a/modules/core/src/main/java/org/apache/ignite/streamer/router/StreamerCacheAffinityEventRouter.java +++ b/modules/core/src/main/java/org/apache/ignite/streamer/router/StreamerCacheAffinityEventRouter.java @@ -18,6 +18,7 @@ package org.apache.ignite.streamer.router; import org.apache.ignite.*; +import org.apache.ignite.cache.*; import org.apache.ignite.cluster.*; import org.apache.ignite.resources.*; import org.apache.ignite.streamer.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java index 0244e9b..b0539a2 100644 --- a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java +++ b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java @@ -28,7 +28,7 @@ import java.util.*; * Grid cache transaction. Cache transactions have a default 2PC (two-phase-commit) behavior and * can be plugged into ongoing {@code JTA} transaction by properly implementing * {@gglink org.gridgain.grid.cache.jta.GridCacheTmLookup} - * interface. Cache transactions can also be started explicitly directly from {@link GridCacheProjection} API + * interface. Cache transactions can also be started explicitly directly from {@link org.apache.ignite.cache.GridCacheProjection} API * via any of the {@code 'GridCacheProjection.txStart(..)'} methods. * <p> * Cache transactions support the following isolation levels: @@ -68,7 +68,7 @@ import java.util.*; * message is sent without waiting for reply. If it is necessary to know whenever remote nodes have committed * as well, synchronous commit or synchronous rollback should be enabled via * {@link CacheConfiguration#setWriteSynchronizationMode} - * or by setting proper flags on cache projection, such as {@link GridCacheFlag#SYNC_COMMIT}. + * or by setting proper flags on cache projection, such as {@link org.apache.ignite.cache.GridCacheFlag#SYNC_COMMIT}. * <p> * Note that in this mode, optimistic failures are only possible in conjunction with * {@link IgniteTxIsolation#SERIALIZABLE} isolation level. In all other cases, optimistic @@ -88,10 +88,10 @@ import java.util.*; * </ul> * <p> * <h1 class="header">Cache Atomicity Mode</h1> - * In addition to standard {@link GridCacheAtomicityMode#TRANSACTIONAL} behavior, GridGain also supports - * a lighter {@link GridCacheAtomicityMode#ATOMIC} mode as well. In this mode distributed transactions + * In addition to standard {@link org.apache.ignite.cache.GridCacheAtomicityMode#TRANSACTIONAL} behavior, GridGain also supports + * a lighter {@link org.apache.ignite.cache.GridCacheAtomicityMode#ATOMIC} mode as well. In this mode distributed transactions * and distributed locking are not supported. Disabling transactions and locking allows to achieve much higher - * performance and throughput ratios. It is recommended that {@link GridCacheAtomicityMode#ATOMIC} mode + * performance and throughput ratios. It is recommended that {@link org.apache.ignite.cache.GridCacheAtomicityMode#ATOMIC} mode * is used whenever full {@code ACID}-compliant transactions are not needed. * <p> * <h1 class="header">Usage</h1> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxSynchronization.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxSynchronization.java b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxSynchronization.java index 7995ae5..54029b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxSynchronization.java +++ b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxSynchronization.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.*; /** * Synchronization callback for transaction. You can subscribe to receive transaction * state change callbacks by registering transaction synchronization via - * {@link GridCache#txSynchronize(IgniteTxSynchronization)} method. + * {@link org.apache.ignite.cache.GridCache#txSynchronize(IgniteTxSynchronization)} method. */ public interface IgniteTxSynchronization { /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java b/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java index 330cc68..52519ec 100644 --- a/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java +++ b/modules/core/src/main/java/org/gridgain/grid/GridBasicWarmupClosure.java @@ -19,6 +19,7 @@ package org.gridgain.grid; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.lang.*; import org.apache.ignite.logger.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java deleted file mode 100644 index 09026ca..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java +++ /dev/null @@ -1,280 +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.gridgain.grid.cache; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.cache.store.CacheStore; -import org.apache.ignite.lang.*; -import org.apache.ignite.transactions.*; -import org.gridgain.grid.cache.affinity.*; -import org.gridgain.grid.cache.affinity.consistenthash.*; -import org.gridgain.grid.cache.datastructures.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * Main entry point for all <b>Data Grid APIs.</b> You can get a named cache by calling {@link org.apache.ignite.Ignite#cache(String)} - * method. - * <h1 class="header">Functionality</h1> - * This API extends {@link GridCacheProjection} API which contains vast majority of cache functionality - * and documentation. In addition to {@link GridCacheProjection} functionality this API provides: - * <ul> - * <li> - * Various {@code 'loadCache(..)'} methods to load cache either synchronously or asynchronously. - * These methods don't specify any keys to load, and leave it to the underlying storage to load cache - * data based on the optionally passed in arguments. - * </li> - * <li> - * Method {@link #affinity()} provides {@link GridCacheAffinityFunction} service for information on - * data partitioning and mapping keys to grid nodes responsible for caching those keys. - * </li> - * <li> - * Method {@link #dataStructures()} provides {@link GridCacheDataStructures} service for - * creating and working with distributed concurrent data structures, such as - * {@link GridCacheAtomicLong}, {@link GridCacheAtomicReference}, {@link GridCacheQueue}, etc. - * </li> - * <li> - * Methods like {@code 'tx{Un}Synchronize(..)'} witch allow to get notifications for transaction state changes. - * This feature is very useful when integrating cache transactions with some other in-house transactions. - * </li> - * <li>Method {@link #metrics()} to provide metrics for the whole cache.</li> - * <li>Method {@link #configuration()} to provide cache configuration bean.</li> - * </ul> - * - * @param <K> Cache key type. - * @param <V> Cache value type. - */ -public interface GridCache<K, V> extends GridCacheProjection<K, V> { - /** - * Gets configuration bean for this cache. - * - * @return Configuration bean for this cache. - */ - public CacheConfiguration configuration(); - - /** - * Registers transactions synchronizations for all transactions started by this cache. - * Use it whenever you need to get notifications on transaction lifecycle and possibly change - * its course. It is also particularly useful when integrating cache transactions - * with some other in-house transactions. - * - * @param syncs Transaction synchronizations to register. - */ - public void txSynchronize(@Nullable IgniteTxSynchronization syncs); - - /** - * Removes transaction synchronizations. - * - * @param syncs Transactions synchronizations to remove. - * @see #txSynchronize(IgniteTxSynchronization) - */ - public void txUnsynchronize(@Nullable IgniteTxSynchronization syncs); - - /** - * Gets registered transaction synchronizations. - * - * @return Registered transaction synchronizations. - * @see #txSynchronize(IgniteTxSynchronization) - */ - public Collection<IgniteTxSynchronization> txSynchronizations(); - - /** - * Gets affinity service to provide information about data partitioning - * and distribution. - * - * @return Cache data affinity service. - */ - public GridCacheAffinity<K> affinity(); - - /** - * Gets data structures service to provide a gateway for creating various - * distributed data structures similar in APIs to {@code java.util.concurrent} package. - * - * @return Cache data structures service. - */ - public GridCacheDataStructures dataStructures(); - - /** - * Gets metrics (statistics) for this cache. - * - * @return Cache metrics. - */ - public GridCacheMetrics metrics(); - - /** - * Gets size (in bytes) of all entries swapped to disk. - * - * @return Size (in bytes) of all entries swapped to disk. - * @throws IgniteCheckedException In case of error. - */ - public long overflowSize() throws IgniteCheckedException; - - /** - * Gets number of cache entries stored in off-heap memory. - * - * @return Number of cache entries stored in off-heap memory. - */ - public long offHeapEntriesCount(); - - /** - * Gets memory size allocated in off-heap. - * - * @return Allocated memory size. - */ - public long offHeapAllocatedSize(); - - /** - * Gets size in bytes for swap space. - * - * @return Size in bytes. - * @throws IgniteCheckedException If failed. - */ - public long swapSize() throws IgniteCheckedException; - - /** - * Gets number of swap entries (keys). - * - * @return Number of entries stored in swap. - * @throws IgniteCheckedException If failed. - */ - public long swapKeys() throws IgniteCheckedException; - - /** - * Gets iterator over keys and values belonging to this cache swap space on local node. This - * iterator is thread-safe, which means that cache (and therefore its swap space) - * may be modified concurrently with iteration over swap. - * <p> - * Returned iterator supports {@code remove} operation which delegates to - * {@link #removex(Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * <h2 class="header">Cache Flags</h2> - * This method is not available if any of the following flags are set on projection: - * {@link GridCacheFlag#SKIP_SWAP}. - * - * @return Iterator over keys. - * @throws IgniteCheckedException If failed. - * @see #promote(Object) - */ - public Iterator<Map.Entry<K, V>> swapIterator() throws IgniteCheckedException; - - /** - * Gets iterator over keys and values belonging to this cache off-heap memory on local node. This - * iterator is thread-safe, which means that cache (and therefore its off-heap memory) - * may be modified concurrently with iteration over off-heap. To achieve better performance - * the keys and values deserialized on demand, whenever accessed. - * <p> - * Returned iterator supports {@code remove} operation which delegates to - * {@link #removex(Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @return Iterator over keys. - * @throws IgniteCheckedException If failed. - */ - public Iterator<Map.Entry<K, V>> offHeapIterator() throws IgniteCheckedException; - - /** - * Delegates to {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method - * to load state from the underlying persistent storage. The loaded values - * will then be given to the optionally passed in predicate, and, if the predicate returns - * {@code true}, will be stored in cache. If predicate is {@code null}, then - * all loaded values will be stored in cache. - * <p> - * Note that this method does not receive keys as a parameter, so it is up to - * {@link CacheStore} implementation to provide all the data to be loaded. - * <p> - * This method is not transactional and may end up loading a stale value into - * cache if another thread has updated the value immediately after it has been - * loaded. It is mostly useful when pre-loading the cache from underlying - * data store before start, or for read-only caches. - * - * @param p Optional predicate (may be {@code null}). If provided, will be used to - * filter values to be put into cache. - * @param ttl Time to live for loaded entries ({@code 0} for infinity). - * @param args Optional user arguments to be passed into - * {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method. - * @throws IgniteCheckedException If loading failed. - */ - public void loadCache(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args) throws IgniteCheckedException; - - /** - * Asynchronously delegates to {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method - * to reload state from the underlying persistent storage. The reloaded values - * will then be given to the optionally passed in predicate, and if the predicate returns - * {@code true}, will be stored in cache. If predicate is {@code null}, then - * all reloaded values will be stored in cache. - * <p> - * Note that this method does not receive keys as a parameter, so it is up to - * {@link CacheStore} implementation to provide all the data to be loaded. - * <p> - * This method is not transactional and may end up loading a stale value into - * cache if another thread has updated the value immediately after it has been - * loaded. It is mostly useful when pre-loading the cache from underlying - * data store before start, or for read-only caches. - * - * @param p Optional predicate (may be {@code null}). If provided, will be used to - * filter values to be put into cache. - * @param ttl Time to live for loaded entries ({@code 0} for infinity). - * @param args Optional user arguments to be passed into - * {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method. - * @return Future to be completed whenever loading completes. - */ - public IgniteFuture<?> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args); - - /** - * Gets a random entry out of cache. In the worst cache scenario this method - * has complexity of <pre>O(S * N/64)</pre> where {@code N} is the size of internal hash - * table and {@code S} is the number of hash table buckets to sample, which is {@code 5} - * by default. However, if the table is pretty dense, with density factor of {@code N/64}, - * which is true for near fully populated caches, this method will generally perform significantly - * faster with complexity of O(S) where {@code S = 5}. - * <p> - * Note that this method is not available on {@link GridCacheProjection} API since it is - * impossible (or very hard) to deterministically return a number value when pre-filtering - * and post-filtering is involved (e.g. projection level predicate filters). - * - * @return Random entry, or {@code null} if cache is empty. - */ - @Nullable public GridCacheEntry<K, V> randomEntry(); - - /** - * Forces this cache node to re-balance its partitions. This method is usually used when - * {@link CacheConfiguration#getPreloadPartitionedDelay()} configuration parameter has non-zero value. - * When many nodes are started or stopped almost concurrently, it is more efficient to delay - * preloading until the node topology is stable to make sure that no redundant re-partitioning - * happens. - * <p> - * In case of{@link GridCacheMode#PARTITIONED} caches, for better efficiency user should - * usually make sure that new nodes get placed on the same place of consistent hash ring as - * the left nodes, and that nodes are restarted before - * {@link CacheConfiguration#getPreloadPartitionedDelay() preloadDelay} expires. To place nodes - * on the same place in consistent hash ring, use - * {@link GridCacheConsistentHashAffinityFunction#setHashIdResolver(GridCacheAffinityNodeHashResolver)} to make sure that - * a node maps to the same hash ID if re-started. - * <p> - * See {@link CacheConfiguration#getPreloadPartitionedDelay()} for more information on how to configure - * preload re-partition delay. - * <p> - * @return Future that will be completed when preloading is finished. - */ - public IgniteFuture<?> forceRepartition(); - - /** - * Resets metrics for current cache. - */ - public void resetMetrics(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicUpdateTimeoutException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicUpdateTimeoutException.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicUpdateTimeoutException.java deleted file mode 100644 index 71eba07..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicUpdateTimeoutException.java +++ /dev/null @@ -1,47 +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.gridgain.grid.cache; - -import org.apache.ignite.*; - -/** - * Exception thrown when atomic operation timeout occurs. - */ -public class GridCacheAtomicUpdateTimeoutException extends IgniteCheckedException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates new timeout exception with given error message. - * - * @param msg Error message. - */ - public GridCacheAtomicUpdateTimeoutException(String msg) { - super(msg); - } - - /** - * Creates new timeout exception with given error message and optional nested exception. - * - * @param msg Error message. - * @param cause Optional nested exception (can be <tt>null</tt>). - */ - public GridCacheAtomicUpdateTimeoutException(String msg, Throwable cause) { - super(msg, cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicWriteOrderMode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicWriteOrderMode.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicWriteOrderMode.java deleted file mode 100644 index 479ad1a..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicWriteOrderMode.java +++ /dev/null @@ -1,64 +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.gridgain.grid.cache; - -import org.jetbrains.annotations.*; - -/** - * Cache write ordering mode. This enumeration is taken into account only in {@link GridCacheAtomicityMode#ATOMIC} - * atomicity mode. Write ordering mode determines which node assigns the write version, sender or the primary node. - * <p> - * For example, {@link #CLOCK} mode assigns write versions on a sender node which generally leads to better - * performance in {@link GridCacheWriteSynchronizationMode#FULL_SYNC} synchronization mode, since in this case - * sender can send write requests to primary and backups at the same time. Otherwise, if ordering mode is - * {@link #PRIMARY}, it would only send request to primary node, which in turn will assign write version - * and forward it to backups. - * <p> - * {@link #CLOCK} mode will be automatically configured only with {@link GridCacheWriteSynchronizationMode#FULL_SYNC} - * write synchronization mode, as for other synchronization modes it does not render better performance. - */ -public enum GridCacheAtomicWriteOrderMode { - /** - * In this mode, write versions are assigned on a sender node which generally leads to better - * performance in {@link GridCacheWriteSynchronizationMode#FULL_SYNC} synchronization mode, since in this case - * sender can send write requests to primary and backups at the same time. - * <p> - * This mode will be automatically configured only with {@link GridCacheWriteSynchronizationMode#FULL_SYNC} - * write synchronization mode, as for other synchronization modes it does not render better performance. - */ - CLOCK, - - /** - * Cache version is assigned only on primary node. This means that sender will only send write request - * to primary node, which in turn will assign write version and forward it to backups. - */ - PRIMARY; - - /** Enumerated values. */ - private static final GridCacheAtomicWriteOrderMode[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static GridCacheAtomicWriteOrderMode fromOrdinal(byte ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicityMode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicityMode.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicityMode.java deleted file mode 100644 index f49afdb..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheAtomicityMode.java +++ /dev/null @@ -1,80 +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.gridgain.grid.cache; - -import org.apache.ignite.cache.*; -import org.apache.ignite.transactions.*; -import org.jetbrains.annotations.*; - -/** - * Cache atomicity mode controls whether cache should maintain fully transactional semantics - * or more light-weight atomic behavior. It is recommended that {@link #ATOMIC} mode is - * used whenever transactions and explicit locking are not needed. Note that in {@link #ATOMIC} - * mode cache will still maintain full data consistency across all cache nodes. - * <p> - * Cache atomicity may be set via {@link CacheConfiguration#getAtomicityMode()} - * configuration property. - */ -public enum GridCacheAtomicityMode { - /** - * Specified fully {@code ACID}-compliant transactional cache behavior. See - * {@link IgniteTx} for more information about transactions. - * <p> - * This mode is currently the default cache atomicity mode. However, cache - * atomicity mode will be changed to {@link #ATOMIC} starting from version {@code 5.2}, - * so it is recommended that desired atomicity mode is explicitly configured - * instead of relying on default value. - */ - TRANSACTIONAL, - - /** - * Specifies atomic-only cache behaviour. In this mode distributed transactions and distributed - * locking are not supported. Disabling transactions and locking allows to achieve much higher - * performance and throughput ratios. - * <p> - * In addition to transactions and locking, one of the main differences in {@code ATOMIC} mode - * is that bulk writes, such as {@code putAll(...)}, {@code removeAll(...)}, and {@code transformAll(...)} - * methods, become simple batch operations which can partially fail. In case of partial - * failure {@link GridCachePartialUpdateException} will be thrown which will contain a list of keys - * for which the update failed. It is recommended that bulk writes are used whenever multiple keys - * need to be inserted or updated in cache, as they reduce number of network trips and provide - * better performance. - * <p> - * Note that even without locking and transactions, {@code ATOMIC} mode still provides - * full consistency guarantees across all cache nodes. - * <p> - * Also note that all data modifications in {@code ATOMIC} mode are guaranteed to be atomic - * and consistent with writes to the underlying persistent store, if one is configured. - * <p> - * This mode is currently implemented for {@link GridCacheMode#PARTITIONED} caches only. - */ - ATOMIC; - - /** Enumerated values. */ - private static final GridCacheAtomicityMode[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static GridCacheAtomicityMode fromOrdinal(int ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheDistributionMode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheDistributionMode.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheDistributionMode.java deleted file mode 100644 index 66f116d..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheDistributionMode.java +++ /dev/null @@ -1,70 +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.gridgain.grid.cache; - -import org.apache.ignite.cache.*; -import org.jetbrains.annotations.*; - -/** - * This enum defines mode in which partitioned cache operates. - * <p> - * Partitioned distribution mode can be configured via {@link CacheConfiguration#getDistributionMode()} - * configuration property. - */ -public enum GridCacheDistributionMode { - /** - * Mode in which local node does not cache any data and communicates with other cache nodes - * via remote calls. - */ - CLIENT_ONLY, - - /** - * Mode in which local node will not be either primary or backup node for any keys, but will cache - * recently accessed keys in a smaller near cache. Amount of recently accessed keys to cache is - * controlled by near eviction policy. - * - * @see CacheConfiguration#getNearEvictionPolicy() - */ - NEAR_ONLY, - - /** - * Mode in which local node may store primary and/or backup keys, and also will cache recently accessed keys. - * Amount of recently accessed keys to cache is controlled by near eviction policy. - * @see CacheConfiguration#getNearEvictionPolicy() - */ - NEAR_PARTITIONED, - - /** - * Mode in which local node may store primary or backup keys, but does not cache recently accessed keys - * in near cache. - */ - PARTITIONED_ONLY; - - /** Enumerated values. */ - private static final GridCacheDistributionMode[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static GridCacheDistributionMode fromOrdinal(int ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java deleted file mode 100644 index e162178..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheEntry.java +++ /dev/null @@ -1,549 +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.gridgain.grid.cache; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.transactions.*; -import org.gridgain.grid.*; -import org.jetbrains.annotations.*; - -import javax.cache.*; -import java.util.*; -import java.util.Map.*; - -/** - * This interface provides a rich API for working with individual cache entries. It - * includes the following main functionality: - * <ul> - * <li> - * Various {@code 'get(..)'} methods to synchronously or asynchronously get values from cache. - * All {@code 'get(..)'} methods are transactional and will participate in an ongoing transaction - * if there is one. - * </li> - * <li> - * Various {@code 'set(..)'}, {@code 'setIfAbsent(..)'}, and {@code 'replace(..)'} methods to - * synchronously or asynchronously put single or multiple entries into cache. - * All these methods are transactional and will participate in an ongoing transaction - * if there is one. - * </li> - * <li> - * Various {@code 'remove(..)'} methods to synchronously or asynchronously remove single or multiple keys - * from cache. All {@code 'remove(..)'} methods are transactional and will participate in an ongoing transaction - * if there is one. - * </li> - * <li> - * Various {@code 'invalidate(..)'} methods to set cached values to {@code null}. - * <li> - * <li> - * Various {@code 'isLocked(..)'} methods to check on distributed locks on a single or multiple keys - * in cache. All locking methods are not transactional and will not enlist keys into ongoing transaction, - * if any. - * </li> - * <li> - * Various {@code 'peek(..)'} methods to peek at values in global or transactional memory, swap - * storage, or persistent storage. - * </li> - * <li> - * Various {@code 'reload(..)'} methods to reload latest values from persistent storage. - * </li> - * <li> - * Method {@link #evict()} to evict elements from cache, and optionally store - * them in underlying swap storage for later access. All {@code 'evict(..)'} methods are not - * transactional and will not enlist evicted keys into ongoing transaction, if any. - * </li> - * <li> - * Methods for {@link #timeToLive(long)} to change or lookup entry's time to live. - * </ul> - * <h1 class="header">Extended Put And Remove Methods</h1> - * All methods that end with {@code 'x'} provide the same functionality as their sibling - * methods that don't end with {@code 'x'}, however instead of returning a previous value they - * return a {@code boolean} flag indicating whether operation succeeded or not. Returning - * a previous value may involve a network trip or a persistent store lookup and should be - * avoided whenever not needed. - * <h1 class="header">Predicate Filters</h1> - * All filters passed into methods on this API are checked <b>atomically</b>. In other words the value - * of cache entry is guaranteed not to change throughout the cache operation. - * <h1 class="header">Transactions</h1> - * Cache API supports distributed transactions. All {@code 'get(..)'}, {@code 'put(..)'}, {@code 'replace(..)'}, - * and {@code 'remove(..)'} operations are transactional and will participate in an ongoing transaction. - * Other methods like {@code 'peek(..)'} may be transaction-aware, i.e. check in-transaction entries first, but - * will not affect the current state of transaction. See {@link IgniteTx} documentation for more information - * about transactions. - * @param <K> Key type. - * @param <V> Value type. - */ -public interface GridCacheEntry<K, V> extends Map.Entry<K, V>, GridMetadataAware, Cache.Entry<K, V> { - /** - * Cache projection to which this entry belongs. Note that entry and its - * parent projections have same flags and filters. - * - * @return Cache projection for the cache to which this entry belongs. - */ - public GridCacheProjection<K, V> projection(); - - /** - * This method has the same semantic as {@link GridCacheProjection#peek(Object)} method. - * - * @return See {@link GridCacheProjection#peek(Object)}. - */ - @Nullable public V peek(); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#peek(Object, Collection)} method. - * - * @param modes See {@link GridCacheProjection#peek(Object, Collection)}. - * @return See {@link GridCacheProjection#peek(Object, Collection)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#peek(Object, Collection)}. - */ - @Nullable public V peek(@Nullable Collection<GridCachePeekMode> modes) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#reload(Object)} method. - * - * @return See {@link GridCacheProjection#reload(Object)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#reload(Object)}. - */ - @Nullable public V reload() throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#reloadAsync(Object)} method. - * - * @return See {@link GridCacheProjection#reloadAsync(Object)}. - */ - public IgniteFuture<V> reloadAsync(); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#isLocked(Object)} method. - * - * @return See {@link GridCacheProjection#isLocked(Object)}. - */ - public boolean isLocked(); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#isLockedByThread(Object)} method. - * - * @return See {@link GridCacheProjection#isLockedByThread(Object)}. - */ - public boolean isLockedByThread(); - - /** - * Gets current version of this cache entry. - * - * @return Version of this cache entry. - */ - public Object version(); - - /** - * Gets expiration time for this entry. - * - * @return Absolute time when this value expires. - */ - public long expirationTime(); - - /** - * Gets time to live, i.e. maximum life time, of this entry in milliseconds. - * - * @return Time to live value for this entry. - */ - public long timeToLive(); - - /** - * Sets time to live, i.e. maximum life time, of this entry in milliseconds. - * Note that this method is transactional - if entry is enlisted into a transaction, - * then time-to-live will not be set until transaction commit. - * <p> - * When called outside the transaction, this method will have no effect until the - * next update operation. - * - * @param ttl Time to live value for this entry. - */ - public void timeToLive(long ttl); - - /** - * Gets the flag indicating current node's primary ownership for this entry. - * <p> - * Note, that this value is dynamic and may change with grid topology changes. - * - * @return {@code True} if current grid node is the primary owner for this entry. - */ - public boolean primary(); - - /** - * Gets the flag indicating if current node is backup for this entry. - * <p> - * Note, that this value is dynamic and may change with grid topology changes. - * - * @return {@code True} if current grid node is the backup for this entry. - */ - public boolean backup(); - - /** - * Gets affinity partition id for this entry. - * - * @return Partition id. - */ - public int partition(); - - /** - * This method has the same semantic as {@link #get()} method, however it - * wraps {@link IgniteCheckedException} into {@link IgniteException} if failed in order to - * comply with {@link Entry} interface. - * - * @return See {@link #get()} - */ - @Nullable @Override public V getValue(); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#get(Object)} method. - * - * @return See {@link GridCacheProjection#get(Object)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#get(Object)}. - */ - @Nullable public V get() throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#getAsync(Object)} method. - * - * @return See {@link GridCacheProjection#getAsync(Object)}. - */ - public IgniteFuture<V> getAsync(); - - /** - * This method has the same semantic as {@link #set(Object, org.apache.ignite.lang.IgnitePredicate[])} method, however it - * wraps {@link IgniteCheckedException} into {@link IgniteException} if failed in order to - * comply with {@link Entry} interface. - * - * @return See {@link #set(Object, org.apache.ignite.lang.IgnitePredicate[])} - */ - @Nullable @Override public V setValue(V val); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @param val See {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} - * @param filter See {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @return See {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @throws IgniteCheckedException See {@link GridCacheProjection#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - */ - @Nullable public V set(V val, @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @param val See {@link GridCacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} - * @param filter See {@link GridCacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @return See {@link GridCacheProjection#putAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - */ - public IgniteFuture<V> setAsync(V val, @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#putIfAbsent(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#putIfAbsent(Object, Object)} - * @return See {@link GridCacheProjection#putIfAbsent(Object, Object)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#putIfAbsent(Object, Object)}. - */ - @Nullable public V setIfAbsent(V val) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#putIfAbsentAsync(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#putIfAbsentAsync(Object, Object)} - * @return See {@link GridCacheProjection#putIfAbsentAsync(Object, Object)}. - */ - public IgniteFuture<V> setIfAbsentAsync(V val); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @param val See {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} - * @param filter See {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @return See {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @throws IgniteCheckedException See {@link GridCacheProjection#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - */ - public boolean setx(V val, @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) - throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @param val See {@link GridCacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} - * @param filter See {@link GridCacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @return See {@link GridCacheProjection#putxAsync(Object, Object, org.apache.ignite.lang.IgnitePredicate[])}. - */ - public IgniteFuture<Boolean> setxAsync(V val, - @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#putxIfAbsent(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#putxIfAbsent(Object, Object)} - * @return See {@link GridCacheProjection#putxIfAbsent(Object, Object)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#putxIfAbsent(Object, Object)}. - */ - public boolean setxIfAbsent(@Nullable V val) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#putxIfAbsentAsync(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#putxIfAbsentAsync(Object, Object)} - * @return See {@link GridCacheProjection#putxIfAbsentAsync(Object, Object)}. - */ - public IgniteFuture<Boolean> setxIfAbsentAsync(V val); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#replace(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#replace(Object, Object)} - * @return See {@link GridCacheProjection#replace(Object, Object)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#replace(Object, Object)}. - */ - @Nullable public V replace(V val) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#replaceAsync(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#replaceAsync(Object, Object)} - * @return See {@link GridCacheProjection#replaceAsync(Object, Object)}. - */ - public IgniteFuture<V> replaceAsync(V val); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#replacex(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#replacex(Object, Object)} - * @return See {@link GridCacheProjection#replacex(Object, Object)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#replacex(Object, Object)}. - */ - public boolean replacex(V val) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#replacexAsync(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#replacexAsync(Object, Object)} - * @return See {@link GridCacheProjection#replacexAsync(Object, Object)}. - */ - public IgniteFuture<Boolean> replacexAsync(V val); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#replace(Object, Object, Object)} method. - * - * @param oldVal See {@link GridCacheProjection#replace(Object, Object, Object)} - * @param newVal See {@link GridCacheProjection#replace(Object, Object, Object)} - * @return See {@link GridCacheProjection#replace(Object, Object)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#replace(Object, Object)}. - */ - public boolean replace(V oldVal, V newVal) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#replaceAsync(Object, Object, Object)} method. - * - * @param oldVal See {@link GridCacheProjection#replaceAsync(Object, Object, Object)} - * @param newVal See {@link GridCacheProjection#replaceAsync(Object, Object, Object)} - * @return See {@link GridCacheProjection#replaceAsync(Object, Object)}. - */ - public IgniteFuture<Boolean> replaceAsync(V oldVal, V newVal); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @param filter See {@link GridCacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @return See {@link GridCacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @throws IgniteCheckedException See {@link GridCacheProjection#remove(Object, org.apache.ignite.lang.IgnitePredicate[])}. - */ - @Nullable public V remove(@Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @param filter See {@link GridCacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @return See {@link GridCacheProjection#removeAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}. - */ - public IgniteFuture<V> removeAsync(@Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @param filter See {@link GridCacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @return See {@link GridCacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @throws IgniteCheckedException See {@link GridCacheProjection#removex(Object, org.apache.ignite.lang.IgnitePredicate[])}. - */ - public boolean removex(@Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])} method. - * - * @param filter See {@link GridCacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}. - * @return See {@link GridCacheProjection#removexAsync(Object, org.apache.ignite.lang.IgnitePredicate[])}. - */ - public IgniteFuture<Boolean> removexAsync(@Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#remove(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#remove(Object, Object)}. - * @return See {@link GridCacheProjection#remove(Object, Object)}. - * @throws IgniteCheckedException See {@link GridCacheProjection#remove(Object, Object)}. - */ - public boolean remove(V val) throws IgniteCheckedException; - - /** - * This method has the same semantic as - * {@link GridCacheProjection#removeAsync(Object, Object)} method. - * - * @param val See {@link GridCacheProjection#removeAsync(Object, Object)}. - * @return See {@link GridCacheProjection#removeAsync(Object, Object)}. - */ - public IgniteFuture<Boolean> removeAsync(V val); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#evict(Object)} method. - * - * @return See {@link GridCacheProjection#evict(Object)}. - */ - public boolean evict(); - - /** - * This method has the same semantic as - * {@link GridCacheProjection#clear(Object)} method. - * - * @return See {@link GridCacheProjection#clear(Object)}. - */ - public boolean clear(); - - /** - * Optimizes the size of this entry. If entry is expired at the time - * of the call then entry is removed locally. - * - * @throws IgniteCheckedException If failed to compact. - * @return {@code true} if entry was cleared from cache (if value was {@code null}). - */ - public boolean compact() throws IgniteCheckedException; - - /** - * Synchronously acquires lock on a cached object associated with this entry - * only if the passed in filter (if any) passes. This method together with - * filter check will be executed as one atomic operation. - * <h2 class="header">Transactions</h2> - * Locks are not transactional and should not be used from within transactions. - * If you do need explicit locking within transaction, then you should use - * {@link IgniteTxConcurrency#PESSIMISTIC} concurrency control for transaction - * which will acquire explicit locks for relevant cache operations. - * <h2 class="header">Cache Flags</h2> - * This method is not available if any of the following flags are set on projection: - * {@link GridCacheFlag#LOCAL}, {@link GridCacheFlag#READ}. - * - * @param timeout Timeout in milliseconds to wait for lock to be acquired - * ({@code '0'} for no expiration). - * @param filter Optional filter to validate prior to acquiring the lock. - * @return {@code True} if all filters passed and lock was acquired, - * {@code false} otherwise. - * @throws IgniteCheckedException If lock acquisition resulted in error. - * @throws GridCacheFlagException If flags validation failed. - */ - public boolean lock(long timeout, @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) - throws IgniteCheckedException; - - /** - * Asynchronously acquires lock on a cached object associated with this entry - * only if the passed in filter (if any) passes. This method together with - * filter check will be executed as one atomic operation. - * <h2 class="header">Transactions</h2> - * Locks are not transactional and should not be used from within transactions. If you do - * need explicit locking within transaction, then you should use - * {@link IgniteTxConcurrency#PESSIMISTIC} concurrency control for transaction - * which will acquire explicit locks for relevant cache operations. - * <h2 class="header">Cache Flags</h2> - * This method is not available if any of the following flags are set on projection: - * {@link GridCacheFlag#LOCAL}, {@link GridCacheFlag#READ}. - * - * @param timeout Timeout in milliseconds to wait for lock to be acquired - * ({@code '0'} for no expiration). - * @param filter Optional filter to validate prior to acquiring the lock. - * @return Future for the lock operation. The future will return {@code true} - * whenever all filters pass and locks are acquired before timeout is expired, - * {@code false} otherwise. - * @throws GridCacheFlagException If flags validation failed. - */ - public IgniteFuture<Boolean> lockAsync(long timeout, - @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter); - - /** - * Unlocks this entry only if current thread owns the lock. If optional filter - * will not pass, then unlock will not happen. If this entry was never locked by - * current thread, then this method will do nothing. - * <h2 class="header">Transactions</h2> - * Locks are not transactional and should not be used from within transactions. If you do - * need explicit locking within transaction, then you should use - * {@link IgniteTxConcurrency#PESSIMISTIC} concurrency control for transaction - * which will acquire explicit locks for relevant cache operations. - * <h2 class="header">Cache Flags</h2> - * This method is not available if any of the following flags are set on projection: - * {@link GridCacheFlag#LOCAL}, {@link GridCacheFlag#READ}. - * - * @param filter Optional filter that needs to pass prior to unlock taking effect. - * @throws IgniteCheckedException If unlock execution resulted in error. - * @throws GridCacheFlagException If flags validation failed. - */ - public void unlock(IgnitePredicate<GridCacheEntry<K, V>>... filter) throws IgniteCheckedException; - - /** - * Checks whether entry is currently present in cache or not. If entry is not in - * cache (e.g. has been removed) {@code false} is returned. In this case all - * operations on this entry will cause creation of a new entry in cache. - * - * @return {@code True} if entry is in cache, {@code false} otherwise. - */ - public boolean isCached(); - - /** - * Gets size of serialized key and value in addition to any overhead added by {@code GridGain} itself. - * - * @return size in bytes. - * @throws IgniteCheckedException If failed to evaluate entry size. - */ - public int memorySize() throws IgniteCheckedException; -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b1a738d/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java deleted file mode 100644 index b6f6185..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java +++ /dev/null @@ -1,111 +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.gridgain.grid.cache; - -import org.apache.ignite.*; -import org.apache.ignite.cache.CacheConfiguration; -import org.apache.ignite.transactions.*; -import org.jetbrains.annotations.*; - -import javax.cache.processor.*; - -/** - * Cache projection flags that specify projection behaviour. This flags can be explicitly passed into - * the following methods on {@link GridCacheProjection}: - * <ul> - * <li>{@link GridCacheProjection#flagsOn(GridCacheFlag...)}</li> - * <li>{@link GridCacheProjection#flagsOff(GridCacheFlag...)}</li> - * </ul> - * Also, some flags, like {@link #LOCAL}, or {@link #READ} may be implicitly set whenever - * creating new projections and passing entries to predicate filters. - */ -public enum GridCacheFlag { - /** - * Only operations that don't require any communication with - * other cache nodes are allowed. This flag is automatically set - * on underlying projection for all the entries that are given to - * predicate filters to make sure that no distribution happens - * from inside of predicate evaluation. - */ - LOCAL, - - /** - * Only operations that don't change cached data are allowed. - * This flag is automatically set on underlying projection for - * all the entries that are given to predicate filters to make - * sure that data cannot be updated during predicate evaluation. - */ - READ, - - /** - * Clone values prior to returning them to user. - * <p> - * Whenever values are returned from cache, they cannot be directly updated - * as cache holds the same references internally. If it is needed to - * update values that are returned from cache, this flag will provide - * automatic cloning of values prior to returning so they can be directly - * updated. - * - * @see CacheConfiguration#getCloner() - */ - CLONE, - - /** Skips store, i.e. no read-through and no write-through behavior. */ - SKIP_STORE, - - /** Skip swap space for reads and writes. */ - SKIP_SWAP, - - /** Synchronous commit. */ - SYNC_COMMIT, - - /** - * Switches a cache projection to work in {@code 'invalidation'} mode. - * Instead of updating remote entries with new values, small invalidation - * messages will be sent to set the values to {@code null}. - * - * @see IgniteTx#isInvalidate() - * @see CacheConfiguration#isInvalidate() - */ - INVALIDATE, - - /** - * Skips version check during {@link IgniteCache#invoke(Object, EntryProcessor, Object[])} writes in - * {@link GridCacheAtomicityMode#ATOMIC} mode. By default, in {@code ATOMIC} mode, whenever - * {@code transform(...)} is called, cache values (and not the {@code transform} closure) are sent from primary - * node to backup nodes to ensure proper update ordering. - * <p> - * By setting this flag, version check is skipped, and the {@code transform} closure is applied on both, primary - * and backup nodes. Use this flag for better performance if you are sure that there are no - * concurrent updates happening for the same key when {@code transform(...)} method is called. - */ - FORCE_TRANSFORM_BACKUP; - - /** */ - private static final GridCacheFlag[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static GridCacheFlag fromOrdinal(int ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -}