Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sboikov committed Jan 21, 2015
1 parent 2be29c8 commit cd78b9c
Show file tree
Hide file tree
Showing 29 changed files with 234 additions and 216 deletions.
Expand Up @@ -51,7 +51,6 @@ public static void main(String[] args) throws IgniteCheckedException {
* @return Grid configuration. * @return Grid configuration.
* @throws IgniteCheckedException If failed. * @throws IgniteCheckedException If failed.
*/ */
@SuppressWarnings("unchecked")
public static IgniteConfiguration configure() throws IgniteCheckedException { public static IgniteConfiguration configure() throws IgniteCheckedException {
IgniteConfiguration cfg = new IgniteConfiguration(); IgniteConfiguration cfg = new IgniteConfiguration();


Expand Down
Expand Up @@ -105,8 +105,7 @@ public class CacheDummyPersonStore extends CacheStoreAdapter<Long, Person> {
/** /**
* @return Current transaction. * @return Current transaction.
*/ */
@Nullable @Nullable private IgniteTx transaction() {
private IgniteTx transaction() {
CacheStoreSession ses = session(); CacheStoreSession ses = session();


return ses != null ? ses.transaction() : null; return ses != null ? ses.transaction() : null;
Expand Down
Expand Up @@ -25,7 +25,6 @@
import org.hibernate.cfg.*; import org.hibernate.cfg.*;
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;


import javax.cache.*;
import javax.cache.integration.*; import javax.cache.integration.*;
import java.util.*; import java.util.*;


Expand Down Expand Up @@ -203,9 +202,9 @@ private void end(Session ses, @Nullable IgniteTx tx) {


IgniteTx tx = storeSes.transaction(); IgniteTx tx = storeSes.transaction();


Map<Object, Object> props = storeSes.properties(); Map<String, Session> props = storeSes.properties();


Session ses = (Session)props.remove(ATTR_SES); Session ses = props.remove(ATTR_SES);


if (ses != null) { if (ses != null) {
Transaction hTx = ses.getTransaction(); Transaction hTx = ses.getTransaction();
Expand Down Expand Up @@ -243,9 +242,9 @@ private Session session(@Nullable IgniteTx tx) {
Session ses; Session ses;


if (tx != null) { if (tx != null) {
Map<Object, Object> props = session().properties(); Map<String, Session> props = session().properties();


ses = (Session)props.get(ATTR_SES); ses = props.get(ATTR_SES);


if (ses == null) { if (ses == null) {
ses = sesFactory.openSession(); ses = sesFactory.openSession();
Expand Down
Expand Up @@ -69,9 +69,9 @@ private void prepareDb() throws IgniteCheckedException {
@Override public void txEnd(boolean commit) { @Override public void txEnd(boolean commit) {
IgniteTx tx = transaction(); IgniteTx tx = transaction();


Map<Object, Object> props = session().properties(); Map<String, Connection> props = session().properties();


try (Connection conn = (Connection)props.remove(ATTR_NAME)) { try (Connection conn = props.remove(ATTR_NAME)) {
if (conn != null) { if (conn != null) {
if (commit) if (commit)
conn.commit(); conn.commit();
Expand Down
Expand Up @@ -19,7 +19,7 @@


import org.apache.ignite.Ignite; import org.apache.ignite.Ignite;
import org.apache.ignite.cache.store.*; import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.*;
import org.apache.ignite.portables.PortableObject; import org.apache.ignite.portables.PortableObject;
import org.apache.ignite.spi.indexing.*; import org.apache.ignite.spi.indexing.*;
import org.gridgain.grid.cache.*; import org.gridgain.grid.cache.*;
Expand All @@ -33,7 +33,6 @@
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;


import javax.cache.configuration.*; import javax.cache.configuration.*;
import javax.cache.integration.*;
import java.util.*; import java.util.*;


/** /**
Expand Down
Expand Up @@ -33,9 +33,6 @@ public enum CacheFlag {
/** Skip swap space for reads and writes. */ /** Skip swap space for reads and writes. */
SKIP_SWAP, SKIP_SWAP,


/** Always get data from primary node (never from backup). */
GET_PRIMARY,

/** Synchronous commit. */ /** Synchronous commit. */
SYNC_COMMIT, SYNC_COMMIT,


Expand Down
@@ -1,10 +1,18 @@
/* @java.file.header */ /*

* 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; package org.apache.ignite.cache;
Expand Down
Expand Up @@ -20,7 +20,6 @@
import org.apache.ignite.*; import org.apache.ignite.*;
import org.apache.ignite.lang.*; import org.apache.ignite.lang.*;
import org.apache.ignite.resources.*; import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*; import org.gridgain.grid.cache.*;
import org.gridgain.grid.util.typedef.internal.*; import org.gridgain.grid.util.typedef.internal.*;
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;
Expand Down Expand Up @@ -102,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 * Note that returned iterator doesn't have to be thread-safe. Thus it could
* operate on raw streams, DB connections, etc. without additional synchronization. * operate on raw streams, DB connections, etc. without additional synchronization.
* *
* @param args Arguments passes into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method. * @param args Arguments passes into {@link GridCache#loadCache(IgniteBiPredicate, long, Object...)} method.
* @return Iterator over input records. * @return Iterator over input records.
* @throws CacheLoaderException If iterator can't be created with the given arguments. * @throws CacheLoaderException If iterator can't be created with the given arguments.
*/ */
Expand All @@ -115,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. * If {@code null} is returned then this record will be just skipped.
* *
* @param rec A raw data record. * @param rec A raw data record.
* @param args Arguments passed into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method. * @param args Arguments passed into {@link 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. * @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); @Nullable protected abstract IgniteBiTuple<K, V> parse(I rec, @Nullable Object... args);
Expand Down Expand Up @@ -277,7 +276,7 @@ private class Worker implements Runnable {
/** /**
* @param c Closure for loaded entries. * @param c Closure for loaded entries.
* @param buf Set of input records to process. * @param buf Set of input records to process.
* @param args Arguments passed into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method. * @param args Arguments passed into {@link GridCache#loadCache(IgniteBiPredicate, long, Object...)} method.
*/ */
Worker(IgniteBiInClosure<K, V> c, Collection<I> buf, Object[] args) { Worker(IgniteBiInClosure<K, V> c, Collection<I> buf, Object[] args) {
this.c = c; this.c = c;
Expand Down
Expand Up @@ -38,7 +38,7 @@
import java.util.concurrent.atomic.*; import java.util.concurrent.atomic.*;


/** /**
* {@link org.apache.ignite.cache.store.CacheStore} implementation backed by JDBC. This implementation * {@link CacheStore} implementation backed by JDBC. This implementation
* stores objects in underlying database in {@code BLOB} format. * stores objects in underlying database in {@code BLOB} format.
* <p> * <p>
* Store will create table {@code ENTRIES} in the database to store data. * Store will create table {@code ENTRIES} in the database to store data.
Expand Down
19 changes: 10 additions & 9 deletions modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
Expand Up @@ -19,6 +19,7 @@


import org.apache.ignite.*; import org.apache.ignite.*;
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.lang.*; import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*; import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.affinity.*; import org.gridgain.grid.cache.affinity.*;
Expand Down Expand Up @@ -187,14 +188,14 @@ public interface GridCache<K, V> extends GridCacheProjection<K, V> {
public Iterator<Map.Entry<K, V>> offHeapIterator() throws IgniteCheckedException; public Iterator<Map.Entry<K, V>> offHeapIterator() throws IgniteCheckedException;


/** /**
* Delegates to {@link org.apache.ignite.cache.store.CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method * Delegates to {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method
* to load state from the underlying persistent storage. The loaded values * 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 * 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 * {@code true}, will be stored in cache. If predicate is {@code null}, then
* all loaded values will be stored in cache. * all loaded values will be stored in cache.
* <p> * <p>
* Note that this method does not receive keys as a parameter, so it is up to * Note that this method does not receive keys as a parameter, so it is up to
* {@link org.apache.ignite.cache.store.CacheStore} implementation to provide all the data to be loaded. * {@link CacheStore} implementation to provide all the data to be loaded.
* <p> * <p>
* This method is not transactional and may end up loading a stale value into * 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 * cache if another thread has updated the value immediately after it has been
Expand All @@ -205,20 +206,20 @@ public interface GridCache<K, V> extends GridCacheProjection<K, V> {
* filter values to be put into cache. * filter values to be put into cache.
* @param ttl Time to live for loaded entries ({@code 0} for infinity). * @param ttl Time to live for loaded entries ({@code 0} for infinity).
* @param args Optional user arguments to be passed into * @param args Optional user arguments to be passed into
* {@link org.apache.ignite.cache.store.CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method. * {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method.
* @throws IgniteCheckedException If loading failed. * @throws IgniteCheckedException If loading failed.
*/ */
public void loadCache(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args) throws IgniteCheckedException; public void loadCache(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args) throws IgniteCheckedException;


/** /**
* Asynchronously delegates to {@link org.apache.ignite.cache.store.CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method * Asynchronously delegates to {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method
* to reload state from the underlying persistent storage. The reloaded values * 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 * 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 * {@code true}, will be stored in cache. If predicate is {@code null}, then
* all reloaded values will be stored in cache. * all reloaded values will be stored in cache.
* <p> * <p>
* Note that this method does not receive keys as a parameter, so it is up to * Note that this method does not receive keys as a parameter, so it is up to
* {@link org.apache.ignite.cache.store.CacheStore} implementation to provide all the data to be loaded. * {@link CacheStore} implementation to provide all the data to be loaded.
* <p> * <p>
* This method is not transactional and may end up loading a stale value into * 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 * cache if another thread has updated the value immediately after it has been
Expand All @@ -229,7 +230,7 @@ public interface GridCache<K, V> extends GridCacheProjection<K, V> {
* filter values to be put into cache. * filter values to be put into cache.
* @param ttl Time to live for loaded entries ({@code 0} for infinity). * @param ttl Time to live for loaded entries ({@code 0} for infinity).
* @param args Optional user arguments to be passed into * @param args Optional user arguments to be passed into
* {@link org.apache.ignite.cache.store.CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method. * {@link CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method.
* @return Future to be completed whenever loading completes. * @return Future to be completed whenever loading completes.
*/ */
public IgniteFuture<?> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args); public IgniteFuture<?> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args);
Expand All @@ -252,20 +253,20 @@ public interface GridCache<K, V> extends GridCacheProjection<K, V> {


/** /**
* Forces this cache node to re-balance its partitions. This method is usually used when * Forces this cache node to re-balance its partitions. This method is usually used when
* {@link org.apache.ignite.cache.CacheConfiguration#getPreloadPartitionedDelay()} configuration parameter has non-zero value. * {@link CacheConfiguration#getPreloadPartitionedDelay()} configuration parameter has non-zero value.
* When many nodes are started or stopped almost concurrently, it is more efficient to delay * 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 * preloading until the node topology is stable to make sure that no redundant re-partitioning
* happens. * happens.
* <p> * <p>
* In case of{@link GridCacheMode#PARTITIONED} caches, for better efficiency user should * 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 * 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 * the left nodes, and that nodes are restarted before
* {@link org.apache.ignite.cache.CacheConfiguration#getPreloadPartitionedDelay() preloadDelay} expires. To place nodes * {@link CacheConfiguration#getPreloadPartitionedDelay() preloadDelay} expires. To place nodes
* on the same place in consistent hash ring, use * on the same place in consistent hash ring, use
* {@link GridCacheConsistentHashAffinityFunction#setHashIdResolver(GridCacheAffinityNodeHashResolver)} to make sure that * {@link GridCacheConsistentHashAffinityFunction#setHashIdResolver(GridCacheAffinityNodeHashResolver)} to make sure that
* a node maps to the same hash ID if re-started. * a node maps to the same hash ID if re-started.
* <p> * <p>
* See {@link org.apache.ignite.cache.CacheConfiguration#getPreloadPartitionedDelay()} for more information on how to configure * See {@link CacheConfiguration#getPreloadPartitionedDelay()} for more information on how to configure
* preload re-partition delay. * preload re-partition delay.
* <p> * <p>
* @return Future that will be completed when preloading is finished. * @return Future that will be completed when preloading is finished.
Expand Down
Expand Up @@ -17,6 +17,7 @@


package org.gridgain.grid.cache; package org.gridgain.grid.cache;


import org.apache.ignite.cache.*;
import org.apache.ignite.transactions.*; import org.apache.ignite.transactions.*;
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;


Expand All @@ -26,7 +27,7 @@
* used whenever transactions and explicit locking are not needed. Note that in {@link #ATOMIC} * 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. * mode cache will still maintain full data consistency across all cache nodes.
* <p> * <p>
* Cache atomicity may be set via {@link org.apache.ignite.cache.CacheConfiguration#getAtomicityMode()} * Cache atomicity may be set via {@link CacheConfiguration#getAtomicityMode()}
* configuration property. * configuration property.
*/ */
public enum GridCacheAtomicityMode { public enum GridCacheAtomicityMode {
Expand Down
Expand Up @@ -17,12 +17,13 @@


package org.gridgain.grid.cache; package org.gridgain.grid.cache;


import org.apache.ignite.cache.*;
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;


/** /**
* This enum defines mode in which partitioned cache operates. * This enum defines mode in which partitioned cache operates.
* <p> * <p>
* Partitioned distribution mode can be configured via {@link org.apache.ignite.cache.CacheConfiguration#getDistributionMode()} * Partitioned distribution mode can be configured via {@link CacheConfiguration#getDistributionMode()}
* configuration property. * configuration property.
*/ */
public enum GridCacheDistributionMode { public enum GridCacheDistributionMode {
Expand All @@ -37,14 +38,14 @@ public enum GridCacheDistributionMode {
* recently accessed keys in a smaller near cache. Amount of recently accessed keys to cache is * recently accessed keys in a smaller near cache. Amount of recently accessed keys to cache is
* controlled by near eviction policy. * controlled by near eviction policy.
* *
* @see org.apache.ignite.cache.CacheConfiguration#getNearEvictionPolicy() * @see CacheConfiguration#getNearEvictionPolicy()
*/ */
NEAR_ONLY, NEAR_ONLY,


/** /**
* Mode in which local node may store primary and/or backup keys, and also will cache recently accessed keys. * 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. * Amount of recently accessed keys to cache is controlled by near eviction policy.
* @see org.apache.ignite.cache.CacheConfiguration#getNearEvictionPolicy() * @see CacheConfiguration#getNearEvictionPolicy()
*/ */
NEAR_PARTITIONED, NEAR_PARTITIONED,


Expand Down

0 comments on commit cd78b9c

Please sign in to comment.