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


Java CacheWriterException类代码示例

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


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

示例1: sessionEnd

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void sessionEnd(boolean commit) throws CacheWriterException {
    Transaction transaction = session.transaction();
    if (transaction == null) {
        return;
    }
    Map<Object, Object> properties = session.properties();
    if (!commit) {
        Map bigBuffer = (Map) properties.get(BUFFER_PROPERTY_NAME);
        if (bigBuffer != null) {
            bigBuffer.remove(cacheName);
        }
    }
    Set<String> caches = (Set<String>) properties.get(CACHES_PROPERTY_NAME);
    if (caches != null && caches.remove(cacheName) && caches.isEmpty()) {
        Map<String, Collection<Cache.Entry<?, ?>>> buffer =
                (Map<String, Collection<Cache.Entry<?, ?>>>) properties.get(BUFFER_PROPERTY_NAME);
        notifyListeners(nextTransactionId(), buffer);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:24,代码来源:DataCapturerBus.java

示例2: handle

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
@Override
public void handle(long transactionId, Map<String, Collection<Cache.Entry<?, ?>>> updates)
        throws CacheWriterException {
    List<Future<RecordMetadata>> futures = producers
            .get()
            .stream()
            .map(producer -> producer.send(transactionId, updates))
            .collect(Collectors.toList());
    try {
        for (Future<RecordMetadata> future : futures) {
            future.get();
        }
    } catch (InterruptedException | ExecutionException e) {
        throw new CacheWriterException(e);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:17,代码来源:SynchronousPublisher.java

示例3: send

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Future<RecordMetadata> send(long transactionId,
    Map<String, Collection<Cache.Entry<?, ?>>> updates) throws CacheWriterException {
    try {
        int partition = partition(transactionId, partitions);
        TransactionScope key = keyTransformer.apply(transactionId, updates);
        List<List> value = valueTransformer.apply(updates);
        ProducerRecord record = new ProducerRecord(dataTopic, partition, transactionId, serializer.serialize(key),
            serializer.serialize(value));
        return producer.send(record);
    }
    catch (Exception e) {
        throw new CacheWriterException(e);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:17,代码来源:TransactionalKafkaProducerImpl.java

示例4: sessionEnd

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void sessionEnd(boolean commit) throws CacheWriterException {
    Transaction transaction = session.transaction();
    if (transaction == null) {
        return;
    }
    Map<Object, Object> properties = session.properties();
    if (!commit) {
        Map bigBuffer = (Map)properties.get(BUFFER_PROPERTY_NAME);
        if (bigBuffer != null) {
            bigBuffer.remove(cacheName);
        }
    }
    Set<String> caches = (Set<String>)properties.get(CACHES_PROPERTY_NAME);
    if (caches != null && caches.remove(cacheName) && caches.isEmpty()) {
        Map<String, Collection<Cache.Entry<?, ?>>> buffer =
            (Map<String, Collection<Cache.Entry<?, ?>>>)properties.get(BUFFER_PROPERTY_NAME);
        notifyListeners(nextTransactionId(), buffer);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:21,代码来源:ActiveCacheStore.java

示例5: sessionEnd

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void sessionEnd(boolean commit) throws CacheWriterException {
    Transaction transaction = session.transaction();
    if (transaction == null) {
        return;
    }
    Map<Object, Object> properties = session.properties();
    if (!commit) {
        Map bigBuffer = (Map)properties.get(BUFFER_PROPERTY_NAME);
        if (bigBuffer != null) {
            bigBuffer.remove(cacheName);
        }
    }
    Set<String> caches = (Set<String>)properties.get(CACHES_PROPERTY_NAME);
    if (caches != null && caches.remove(cacheName) && caches.isEmpty() && !isOnDRCluster()) {
        Map<String, Collection<Cache.Entry<?, ?>>> buffer =
            (Map<String, Collection<Cache.Entry<?, ?>>>)properties.get(BUFFER_PROPERTY_NAME);
        notifyListeners(nextTransactionId(), buffer);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:21,代码来源:ActiveCacheStore.java

示例6: writeTransaction

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
@Override public void writeTransaction(long transactionId, Map<String, Collection<Cache.Entry<?, ?>>> updates)
    throws CacheWriterException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("[M] Writing synchronous replica for transaction {} with size of batch {}",
                transactionId, updates.size());
    }
    Collection<RemoteKafkaProducer> producers = replicaProducersManager.getProducers();

    if (!producers.isEmpty()) {
        List<Future<RecordMetadata>> futures = new ArrayList<>(producers.size());
        for (RemoteKafkaProducer producer : producers) {
            futures.add(producer.writeTransaction(transactionId, updates));
        }
        wait(futures);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:17,代码来源:SynchronousPublisher.java

示例7: delete

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings({"JpaQueryApiInspection"})
@Override public void delete(Object key) {
    System.out.println(">>> Store delete [key=" + key + ']');

    Session hibSes = ses.attachment();

    try {
        hibSes.createQuery("delete " + Person.class.getSimpleName() + " where key = :key").
            setParameter("key", key).
            executeUpdate();
    }
    catch (HibernateException e) {
        throw new CacheWriterException("Failed to remove value from cache store [key=" + key + ']', e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:CacheHibernatePersonStore.java

示例8: onSessionEnd

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
    Session hibSes = ses.attach(null);

    if (hibSes != null) {
        try {
            Transaction tx = hibSes.getTransaction();

            if (commit) {
                if (hibSes.isDirty())
                    hibSes.flush();

                if (tx.getStatus() == TransactionStatus.ACTIVE)
                    tx.commit();
            }
            else if (tx.getStatus().canRollback())
                tx.rollback();
        }
        catch (HibernateException e) {
            throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
        }
        finally {
            hibSes.close();
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:CacheHibernateStoreSessionListener.java

示例9: write

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) {
    Long key = entry.getKey();
    Person val = entry.getValue();

    System.out.println(">>> Store write [key=" + key + ", val=" + val + ']');

    Session hibSes = ses.attachment();

    try {
        hibSes.saveOrUpdate(val);
    }
    catch (HibernateException e) {
        throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:CacheHibernatePersonStore.java

示例10: onSessionStart

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionStart(CacheStoreSession ses) {
    if (ses.attachment() == null) {
        try {
            Session hibSes = sesFactory.openSession();

            ses.attach(hibSes);

            if (ses.isWithinTransaction())
                hibSes.beginTransaction();
        }
        catch (HibernateException e) {
            throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:CacheHibernateStoreSessionListener.java

示例11: onSessionEnd

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
    Session hibSes = ses.attach(null);

    if (hibSes != null) {
        try {
            Transaction tx = hibSes.getTransaction();

            if (commit) {
                hibSes.flush();

                if (tx.isActive())
                    tx.commit();
            }
            else if (tx.isActive())
                tx.rollback();
        }
        catch (HibernateException e) {
            throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
        }
        finally {
            hibSes.close();
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:CacheHibernateStoreSessionListener.java

示例12: sessionEnd

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void sessionEnd(boolean commit) throws CacheWriterException {
    if (!storeSes.isWithinTransaction())
        return;

    List<Mutation> mutations = mutations();
    if (mutations == null || mutations.isEmpty())
        return;

    CassandraSession ses = getCassandraSession();

    try {
        ses.execute(mutations);
    }
    finally {
        mutations.clear();
        U.closeQuiet(ses);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:CassandraCacheStore.java

示例13: delete

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void delete(final Object key) {
    try {
        doInvoke(new IgniteInClosureX<BinaryRawWriterEx>() {
            @Override public void applyx(BinaryRawWriterEx writer) throws IgniteCheckedException {
                writer.writeByte(OP_RMV);
                writer.writeLong(session());
                writer.writeString(ses.cacheName());
                writer.writeObject(key);
            }
        }, null);
    }
    catch (IgniteCheckedException e) {
        throw new CacheWriterException(U.convertExceptionNoWrap(e));
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:PlatformDotNetCacheStore.java

示例14: deleteAll

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void deleteAll(final Collection<?> keys) {
    try {
        doInvoke(new IgniteInClosureX<BinaryRawWriterEx>() {
            @Override public void applyx(BinaryRawWriterEx writer) throws IgniteCheckedException {
                writer.writeByte(OP_RMV_ALL);
                writer.writeLong(session());
                writer.writeString(ses.cacheName());

                writer.writeInt(keys.size());

                for (Object o : keys)
                    writer.writeObject(o);
            }
        }, null);
    }
    catch (IgniteCheckedException e) {
        throw new CacheWriterException(U.convertExceptionNoWrap(e));
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:PlatformDotNetCacheStore.java

示例15: onSessionEnd

import javax.cache.integration.CacheWriterException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
    Connection conn = ses.attach(null);

    if (conn != null) {
        try {
            if (commit)
                conn.commit();
            else
                conn.rollback();
        }
        catch (SQLException e) {
            throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
        }
        finally {
            U.closeQuiet(conn);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:CacheJdbcStoreSessionListener.java


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