当前位置: 首页>>代码示例>>Java>>正文


Java CacheLoaderException类代码示例

本文整理汇总了Java中javax.cache.integration.CacheLoaderException的典型用法代码示例。如果您正苦于以下问题:Java CacheLoaderException类的具体用法?Java CacheLoaderException怎么用?Java CacheLoaderException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CacheLoaderException类属于javax.cache.integration包,在下文中一共展示了CacheLoaderException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadAll

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public <K, V> Map<K, V> loadAll(Iterable<? extends K> keys, String cacheName, Iterable<Metadata> path)
        throws CacheLoaderException {
    Map<K, V> result = new HashMap<>();
    for (Metadata metadata : path) {
        Map map = loadAll(keys, cacheName, metadata);
        List<K> next = new ArrayList<>();
        for (K key : keys) {
            Object value = map.get(key);
            if (value == null) {
                next.add(key);
            }
            else {
                result.put(key, ActiveCacheStore.TOMBSTONE.equals(value) ? null : (V)value);
            }
        }
        if (next.isEmpty()) {
            break;
        }
        else {
            keys = next;
        }
    }
    return result;
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:26,代码来源:InMemoryKeyValueProvider.java

示例2: createFilter

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
static Optional<Filter> createFilter(Object[] args) {
  if (args.length == 0) {
    return Optional.empty();
  }
  FilterList filters = new FilterList();
  for (int i = 0; i < args.length; i++) {
    Object filter = args[i];
    try {
      checkArgument(filter instanceof Filter,
          "Filter " + i + " must be of type " + Filter.class.getName()
              + " but is of type " + filter.getClass().getName());
    } catch (IllegalArgumentException e) {
      throw new CacheLoaderException(e);
    }
    filters.addFilter((Filter) filter);
  }
  return Optional.of(filters);
}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:19,代码来源:FilterParser.java

示例3: loadCache

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
@Override
public void loadCache(IgniteBiInClosure<Integer, SpatialPartition>
                             igniteBiInClosure, @Nullable Object... objects)
        throws CacheLoaderException {
    IgniteCache<Integer,SpatialPartition> cache =
            (IgniteCache<Integer,SpatialPartition>) objects[0];
    Integer key = (Integer) objects[1];
    ArrayList<Long> values = (ArrayList<Long>) objects[2];

    SpatialPartition curr_value = cache.get(key);
    if(curr_value == null)
        curr_value = new SpatialPartition(values);
    else
        curr_value.mergeData(values);
    cache.put(key, curr_value);
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:17,代码来源:BulkLoadSpatialCacheStore.java

示例4: load

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/** {@inheritDoc} */
@Nullable @Override public V load(final K key) {
    try {
        final GridTuple<V> val = new GridTuple<>();

        doInvoke(new IgniteInClosureX<BinaryRawWriterEx>() {
            @Override public void applyx(BinaryRawWriterEx writer) throws IgniteCheckedException {
                writer.writeByte(OP_LOAD);
                writer.writeLong(session());
                writer.writeString(ses.cacheName());
                writer.writeObject(key);
            }
        }, new IgniteInClosureX<BinaryRawReaderEx>() {
            @Override public void applyx(BinaryRawReaderEx reader) {
                val.set((V)reader.readObjectDetached());
            }
        });

        return val.get();
    }
    catch (IgniteCheckedException e) {
        throw new CacheLoaderException(e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:PlatformDotNetCacheStore.java

示例5: loadCache

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void loadCache(final IgniteBiInClosure<K, V> clo, final @Nullable Object... args) {
    try {
        doInvoke(new IgniteInClosureX<BinaryRawWriterEx>() {
            @Override public void applyx(BinaryRawWriterEx writer) throws IgniteCheckedException {
                writer.writeByte(OP_LOAD_CACHE);
                writer.writeLong(session());
                writer.writeString(ses.cacheName());
                writer.writeObjectArray(args);
            }
        }, new IgniteInClosureX<BinaryRawReaderEx>() {
            @Override public void applyx(BinaryRawReaderEx reader) {
                int cnt = reader.readInt();

                for (int i = 0; i < cnt; i++)
                    clo.apply((K) reader.readObjectDetached(), (V) reader.readObjectDetached());
            }
        });
    }
    catch (IgniteCheckedException e) {
        throw new CacheLoaderException(e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:PlatformDotNetCacheStore.java

示例6: buildBinaryObject

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/**
 * Construct binary object from query result.
 *
 * @param typeName Type name.
 * @param fields Fields descriptors.
 * @param loadColIdxs Select query columns index.
 * @param rs ResultSet.
 * @return Constructed binary object.
 * @throws CacheLoaderException If failed to construct binary object.
 */
protected Object buildBinaryObject(String typeName, JdbcTypeField[] fields, Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException {
    try {
        BinaryObjectBuilder builder = ignite.binary().builder(typeName);

        for (JdbcTypeField field : fields) {
            Integer colIdx = columnIndex(loadColIdxs, field.getDatabaseFieldName());

            Object colVal = transformer.getColumnValue(rs, colIdx, field.getJavaFieldType());

            builder.setField(field.getJavaFieldName(), colVal, (Class<Object>)field.getJavaFieldType());
        }

        return builder.build();
    }
    catch (SQLException e) {
        throw new CacheException("Failed to read binary object: " + typeName, e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:29,代码来源:CacheJdbcPojoStore.java

示例7: checkGetError

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/**
 * @param nearEnabled Near cache flag.
 * @param cacheMode Cache mode.
 * @throws Exception If failed.
 */
private void checkGetError(boolean nearEnabled, CacheMode cacheMode) throws Exception {
    this.nearEnabled = nearEnabled;
    this.cacheMode = cacheMode;

    startGrids(3);

    try {
        GridTestUtils.assertThrows(log, new Callable<Object>() {
            @Override public Object call() throws Exception {
                grid(0).cache(DEFAULT_CACHE_NAME).get(nearKey());

                return null;
            }
        }, CacheLoaderException.class, null);
    }
    finally {
        stopAllGrids();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:GridCacheGetStoreErrorSelfTest.java

示例8: inputIterator

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected Iterator<String> inputIterator(@Nullable Object... args) throws CacheLoaderException {
    return new Iterator<String>() {
        private int i;

        @Override public boolean hasNext() {
            return i < inputSize;
        }

        @Override public String next() {
            if (!hasNext())
                throw new NoSuchElementException();

            String res = i + "=str" + i;

            i++;

            return res;
        }

        @Override public void remove() {
            // No-op.
        }
    };
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:GridCacheLoadOnlyStoreAdapterSelfTest.java

示例9: testLoadNotRegisteredType

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testLoadNotRegisteredType() throws Exception {
    startTestGrid(false, false, false, false, 512);

    IgniteCache<Object, Object> c1 = grid().cache(CACHE_NAME);

    try {
        c1.loadCache(null, "PersonKeyWrong", "SELECT * FROM Person");
    }
    catch (CacheLoaderException e) {
        String msg = e.getMessage();

        assertTrue("Unexpected exception: " + msg,
            ("Provided key type is not found in store or cache configuration " +
                "[cache=" + CACHE_NAME + ", key=PersonKeyWrong]").equals(msg));
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:CacheJdbcPojoStoreAbstractSelfTest.java

示例10: loadCache

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void loadCache(IgniteBiInClosure<String, String> clo, @Nullable Object... args) {
    if (args.length > 0) {
        try {
            int cnt = ((Number)args[0]).intValue();
            int postfix = ((Number)args[1]).intValue();

            for (int i = 0; i < cnt; i++)
                clo.apply("key" + i, "val." + cacheName + "." + postfix);
        }
        catch (Exception e) {
            X.println("Unexpected exception in loadAll: " + e);

            throw new CacheLoaderException(e);
        }
    }
    else {
        for (int i = 0; i < DFLT_GEN_CNT; i++)
            clo.apply("key" + i, "val." + cacheName + "." + i);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:GridGeneratingTestStore.java

示例11: loadCache

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void loadCache(final IgniteBiInClosure<Long, Person> clo, Object... args) {
    if (args == null || args.length == 0 || args[0] == null)
        throw new CacheLoaderException("Expected entry count parameter is not provided.");

    int entryCnt = (Integer)args[0];

    final AtomicInteger cnt = new AtomicInteger();

    jdbcTemplate.query("select * from PERSON limit ?", new RowCallbackHandler() {
        @Override public void processRow(ResultSet rs) throws SQLException {
            Person person = new Person(rs.getLong(1), rs.getString(2), rs.getString(3));

            clo.apply(person.id, person);

            cnt.incrementAndGet();
        }
    }, entryCnt);

    System.out.println(">>> Loaded " + cnt + " values into cache.");
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:CacheSpringPersonStore.java

示例12: load

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Person load(Long key) {
    System.out.println(">>> Store load [key=" + key + ']');

    Connection conn = ses.attachment();

    try (PreparedStatement st = conn.prepareStatement("select * from PERSON where id = ?")) {
        st.setString(1, key.toString());

        ResultSet rs = st.executeQuery();

        return rs.next() ? new Person(rs.getLong(1), rs.getString(2), rs.getString(3)) : null;
    }
    catch (SQLException e) {
        throw new CacheLoaderException("Failed to load object [key=" + key + ']', e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:CacheJdbcPersonStore.java

示例13: shouldPropagateExceptionUsingLoadAll

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/**
 * Ensure that {@link Cache#loadAll(java.util.Set, boolean, javax.cache.integration.CompletionListener)}  )}
 * will propagate an exception from a {@link javax.cache.integration.CacheLoader}.
 */
@Test
public void shouldPropagateExceptionUsingLoadAll() throws Exception {
  FailingCacheLoader<String, String> cacheLoader = new FailingCacheLoader<>();
  cacheLoaderServer.setCacheLoader(cacheLoader);

  HashSet<String> keys = new HashSet<>();
  keys.add("gudday");
  keys.add("hello");
  keys.add("howdy");
  keys.add("bonjour");

  CompletionListenerFuture future = new CompletionListenerFuture();
  cache.loadAll(keys, false, future);

  //wait for the load to complete
  try {
    future.get();
    fail(); // new since TCK 1.1
  } catch (ExecutionException e) {
    assertThat(e.getCause(), instanceOf(CacheLoaderException.class));
  }
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:27,代码来源:CacheLoaderWithoutReadThroughTest.java

示例14: shouldPropagateExceptionUsingLoadAll

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
/**
 * Ensure that {@link Cache#loadAll(java.util.Set, boolean, javax.cache.integration.CompletionListener)}  )}
 * will propagate an exception from a {@link CacheLoader}.
 */
@Test
public void shouldPropagateExceptionUsingLoadAll() throws Exception {
  FailingCacheLoader<String, String> cacheLoader = new FailingCacheLoader<>();
  cacheLoaderServer.setCacheLoader(cacheLoader);

  HashSet<String> keys = new HashSet<>();
  keys.add("gudday");
  keys.add("hello");
  keys.add("howdy");
  keys.add("bonjour");

  CompletionListenerFuture future = new CompletionListenerFuture();
  cache.loadAll(keys, false, future);

  //wait for the load to complete
  try{
    future.get();
    fail(); // new since TCK 1.1
  } catch (ExecutionException e) {
    assertThat(e.getCause(), instanceOf(CacheLoaderException.class));
  }
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:27,代码来源:CacheLoaderTest.java

示例15: loadValue

import javax.cache.integration.CacheLoaderException; //导入依赖的package包/类
private V loadValue(K key) {
    V value = null;
    try {
        value = cacheLoader.load(key);
    } catch (Exception ex) {
        throw new CacheLoaderException(ex);
    }
    if (value != null) {
        long startTime = currentNanoTime();
        putValueLocked(key, value);
        cacheManager.getStatBean(this).addGetTime(currentNanoTime() - startTime);
    }
    return value;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:15,代码来源:JCache.java


注:本文中的javax.cache.integration.CacheLoaderException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。