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


Java CacheException类代码示例

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


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

示例1: execute

import javax.cache.CacheException; //导入依赖的package包/类
public <R> Future<R> execute(String key, IgniteCache<Long, V> cache, BiFunction<String, IgniteCache<Long, V>, R> function) {
    return Futures.future(() -> {
        R result = null;
        try {
            result = function.apply(key, cache);
            // in case it is client node , client reconnect with 300 milliseconds timeout is used to retry to connect again to the server nodes grid
        } catch (IgniteClientDisconnectedException e) {
            e.reconnectFuture().get(300, TimeUnit.MILLISECONDS);
            result = function.apply(key, cache);
        } catch (CacheException cacheException) {
            if (cacheException.getCause() instanceof IgniteClientDisconnectedException) {
                ((IgniteClientDisconnectedException) cacheException.getCause()).reconnectFuture().get(300, TimeUnit.MILLISECONDS);
                result = function.apply(key, cache);
            }
        }
        return result;
    }, dispatcher);

}
 
开发者ID:Romeh,项目名称:akka-persistance-ignite,代码行数:20,代码来源:Store.java

示例2: verifyIntegrity

import javax.cache.CacheException; //导入依赖的package包/类
private void verifyIntegrity(String familyName) throws CacheException {
  if (tableName == null) {
    String msg = "TableName must not be null";
    logger.warning(msg);
    throw new CacheException(msg);
  }
  if (!ensuredColumnFamilies.contains(familyName)) {
    try {
      HBaseUtil.ensureTableAndColumnFamilyExist(conn, tableName, familyName);
      ensuredColumnFamilies.add(familyName);
    } catch (IOException e) {
      logger.warning(
          "Error ensuring that HBase table '" + tableName + "' and column family '"
              + familyName + "' exists", e);
      throw new CacheException(e);
    }
  }
}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:19,代码来源:HBaseCacheStoreSessionListener.java

示例3: get

import javax.cache.CacheException; //导入依赖的package包/类
@Override
public V get(K key)
{
    checkState();

    if (key == null)
    {
        throw new NullPointerException();
    }

    if (configuration.isReadThrough())
    {
        try
        {
            return ((LoadingCache<K, V>) cache).get(key);
        }
        catch (ExecutionException e)
        {
            throw new CacheException(e);
        }
    }

    return cache.getIfPresent(key);
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:25,代码来源:GuavaCache.java

示例4: getAll

import javax.cache.CacheException; //导入依赖的package包/类
@Override
public Map<K, V> getAll(Set<? extends K> keys)
{
    checkState();

    if (keys == null || keys.contains(null))
    {
        throw new NullPointerException();
    }

    if (configuration.isReadThrough())
    {
        try
        {
            return ((LoadingCache<K, V>) cache).getAll(keys);
        }
        catch (ExecutionException e)
        {
            throw new CacheException(e);
        }
    }

    return cache.getAllPresent(keys);
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:25,代码来源:GuavaCache.java

示例5: getCacheManagerWithNonNullProperties

import javax.cache.CacheException; //导入依赖的package包/类
@Test // org.jsr107.tck.CacheManagerTest.getCacheManager_nonNullProperties
public void getCacheManagerWithNonNullProperties()
{
    // see https://github.com/jsr107/jsr107tck/issues/102

    // make sure existing cache managers are closed and the non empty properties get picked up
    try
    {
        Caching.getCachingProvider().close();
    }
    catch (CacheException ignore)
    {
        // ignore exception which may happen if the provider is not active
    }

    CachingProvider provider = Caching.getCachingProvider();

    Properties properties = new Properties();
    properties.put("dummy.com", "goofy");

    provider.getCacheManager(provider.getDefaultURI(), provider.getDefaultClassLoader(), properties);
    CacheManager manager = provider.getCacheManager();

    assertEquals(properties, manager.getProperties());
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:26,代码来源:GuavaCacheManagerTest.java

示例6: createManager

import javax.cache.CacheException; //导入依赖的package包/类
public CacheManager createManager(Map<String, Configuration<?, ?>> configs, ShutdownManager shutdownManager) {

        CachingProvider provider;
        try {
            // TODO: an explicit config property to pick explicit provider out of available choices... though probably
            // pointless in most cases (do we realistically expect multiple providers on classpath?)
            provider = Caching.getCachingProvider();
        } catch (CacheException e) {
            throw new RuntimeException("'bootique-jcache' doesn't bundle any JCache providers. " +
                    "You must place a JCache 1.0 provider on classpath explicitly.", e);
        }

        shutdownManager.addShutdownHook(provider);

        CacheManager manager = getConfigUri().map(u -> provider.getCacheManager(u, null)).orElse(provider.getCacheManager());
        shutdownManager.addShutdownHook(manager);

        // now load contributed configs
        configs.forEach(manager::createCache);

        return manager;
    }
 
开发者ID:bootique,项目名称:bootique-jcache,代码行数:23,代码来源:JCacheFactory.java

示例7: query

import javax.cache.CacheException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public <T, R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T, R> transformer) {
    A.notNull(qry, "qry");
    A.notNull(transformer, "transformer");

    if (!(qry instanceof ScanQuery))
        throw new UnsupportedOperationException("Transformers are supported only for SCAN queries.");

    try {
        ctx.checkSecurity(SecurityPermission.CACHE_READ);

        validate(qry);

        return query((ScanQuery<K, V>)qry, transformer, projection(qry.isLocal()));
    }
    catch (Exception e) {
        if (e instanceof CacheException)
            throw (CacheException)e;

        throw new CacheException(e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:IgniteCacheProxyImpl.java

示例8: putAll

import javax.cache.CacheException; //导入依赖的package包/类
@Override
public void putAll(Map<? extends K, ? extends V> map) {
    verifyCacheConnectivity();
    Object[] keys = new Object[map.size()];
    CacheItem[] cItems = new CacheItem[map.size()];
    int i = 0;
    for(Map.Entry e : map.entrySet())
    {
        if(e.getKey() == null)
            throw  new NullPointerException("key cannot be null.");
        if(e.getValue() == null)
            throw new NullPointerException("value cannot be null.");
        keys[i] = e.getKey();
        cItems[i] = new CacheItem(e.getValue());
        i++;            
    }
    try {
        innerCache.insertBulk(keys, cItems, DSWriteOption.OptionalWriteThru, null);
    } 
    catch (Exception ex) {
        throw new CacheException(ex);
    }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:24,代码来源:TayzGridCache.java

示例9: replace

import javax.cache.CacheException; //导入依赖的package包/类
@Override
public boolean replace(K key, V oldValue, V newValue) {
    verifyCacheConnectivity();
    if(key==null)
        throw new NullPointerException("key cannot be null.");
    if(newValue == null)
        throw new NullPointerException("value cannot be null.");
    try {
        //--TODO--
        InsertParams options = new InsertParams();
        options.IsReplaceOperation = true;
        options.CompareOldValue = true;
        options.OldValue = oldValue;
        InsertResult result = innerCache.insertInternal(key, newValue, DSWriteOption.OptionalWriteThru, options);
        return result.Success;
    } catch (Exception ex) {
        throw new CacheException(ex);
    }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:20,代码来源:TayzGridCache.java

示例10: registerCache

import javax.cache.CacheException; //导入依赖的package包/类
/**
 * Registers a Cache to this factory. Registered caches will be used for bulk operations like
 * {@link #close()}.
 * 
 * @param cache The Cache to register
 *  @throws IllegalStateException If a cache with the same id is already registered in this factory.
 */
public void registerCache(Cache<?, ?> cache)
{
	assertNotClosed();
	
	String id = cache.id();
	synchronized (factoryLock)
	{
		for (Cache<?, ?> registeredCache : CacheInstances)
		{
			if (registeredCache.id().equals(id))
			{
				throw new CacheException("Cache with the same id is already registered: " + id);
			}
		}

		CacheInstances.add(cache);			
		// Hint: "cache" cannot escape. It is safely published, as it is put in a concurrent collection
	}
}
 
开发者ID:trivago,项目名称:triava,代码行数:27,代码来源:TCacheFactory.java

示例11: register

import javax.cache.CacheException; //导入依赖的package包/类
public void register(Cache<?,?> cache)
{
	TCacheJSR107<?, ?> jsr107cache = cache.jsr107cache();
	// these can change during runtime, so always look it up
	ObjectName registeredObjectName = calculateObjectName(jsr107cache, objectNameType());
	if (isRegistered(registeredObjectName))
	{
		// Do not register twice. Actually this contains a race condition due to a
		// check-then-act "isRegistered() => registerMBean()" action, but it should not be
		// a problem for us, because there are never two caches with the same name alive at the
		// same time.
		return;
	}
	
	try
	{
		mBeanServer.registerMBean(getMBean(jsr107cache), registeredObjectName);
	}
	catch (Exception e)
	{
		throw new CacheException("Error registering cache MXBeans for CacheManager " + registeredObjectName
				+ " . Error was " + e.getMessage(), e);
	}
}
 
开发者ID:trivago,项目名称:triava,代码行数:25,代码来源:TCacheMBean.java

示例12: unregister

import javax.cache.CacheException; //导入依赖的package包/类
public void unregister(Cache<?, ?> cache)
{
	TCacheJSR107<?, ?> jsr107cache = cache.jsr107cache();

	ObjectName objectName = calculateObjectName(jsr107cache, objectNameType());
	Set<ObjectName> registeredObjectNames = mBeanServer.queryNames(objectName, null);

	// should just be one
	for (ObjectName registeredObjectName : registeredObjectNames)
	{
		try
		{
			mBeanServer.unregisterMBean(registeredObjectName);
		}
		catch (Exception e)
		{
			throw new CacheException("Error unregistering object instance " + registeredObjectName
					+ " . Error was " + e.getMessage(), e);
		}
	}

}
 
开发者ID:trivago,项目名称:triava,代码行数:23,代码来源:TCacheMBean.java

示例13: calculateObjectName

import javax.cache.CacheException; //导入依赖的package包/类
/**
 * Creates an object name using the scheme
 * "javax.cache:type=Cache&lt;Statistics|Configuration&gt;,CacheManager=&lt;cacheManagerName&gt;,name=&lt;cacheName&gt;"
 * <p>
 * Implementation note: Method modeled after the JSR107 RI
 */
private static ObjectName calculateObjectName(javax.cache.Cache<?, ?> cache, String objectNameType)
{
	String cacheManagerName = mbeanSafe(cache.getCacheManager().getURI().toString());
	String cacheName = mbeanSafe(cache.getName());

	try
	{
		/**
		 * JSR107 There seems to be a naming mismatch.
		 * - (correct) The RI uses "type=CacheConfiguration" and "type=CacheStatistics" 
		 * - (wrong) The API docs of CacheManager.enableManagement() specify "type=Cache" and "type=CacheStatistics" 
		 */
		return new ObjectName("javax.cache:type=Cache" + objectNameType + ",CacheManager=" + cacheManagerName
				+ ",Cache=" + cacheName);
	}
	catch (MalformedObjectNameException e)
	{
		throw new CacheException("Illegal ObjectName for Management Bean. " + "CacheManager=[" + cacheManagerName
				+ "], Cache=[" + cacheName + "] type=[" + objectNameType + "]", e);
	}
}
 
开发者ID:trivago,项目名称:triava,代码行数:28,代码来源:TCacheMBean.java

示例14: testTimeoutOnCloseMethod

import javax.cache.CacheException; //导入依赖的package包/类
/**
 * Test timeout on {@code DataStreamer.addData()} method
 * @throws Exception If fail.
 */
public void testTimeoutOnCloseMethod() throws Exception {
    failOn = 1;

    Ignite ignite = startGrid(1);

    boolean thrown = false;

    try (IgniteDataStreamer ldr = ignite.dataStreamer(CACHE_NAME)) {
        ldr.timeout(TIMEOUT);
        ldr.receiver(new TestDataReceiver());
        ldr.perNodeBufferSize(ENTRY_AMOUNT);

        for (int i = 0; i < ENTRY_AMOUNT; i++)
            ldr.addData(i, i);
    }
    catch (CacheException | IgniteDataStreamerTimeoutException ignored) {
        thrown = true;
    }
    finally {
        stopAllGrids();
    }

    assertTrue(thrown);
}
 
开发者ID:apache,项目名称:ignite,代码行数:29,代码来源:DataStreamerTimeoutTest.java

示例15: serialize

import javax.cache.CacheException; //导入依赖的package包/类
private ByteArray serialize(Object key)
{
	if (key == null)
	{
		throw new NullPointerException("key must not be null");
	}

	try
	{
		return new ByteArray(Serializing.toBytearray(key));
	}
	catch (IOException e)
	{
		throw new CacheException("Cannot serialize key class of type: " + key.getClass().getName() , e);
	}
}
 
开发者ID:trivago,项目名称:triava,代码行数:17,代码来源:ConcurrentKeyDeserMap.java


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