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


Java SerializableException.serializeToBuffer方法代码示例

本文整理汇总了Java中org.voltdb.exceptions.SerializableException.serializeToBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java SerializableException.serializeToBuffer方法的具体用法?Java SerializableException.serializeToBuffer怎么用?Java SerializableException.serializeToBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.voltdb.exceptions.SerializableException的用法示例。


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

示例1: testPrepareShutdownSerializeError

import org.voltdb.exceptions.SerializableException; //导入方法依赖的package包/类
/**
 * testPrepareShutdownSerializeError
 */
@Test
public void testPrepareShutdownSerializeError() throws Exception {
    String errorMsg = "XXXXXXXXX";
    Throwable error = null;
    try {
        throw new RuntimeException(errorMsg);
    } catch (Throwable ex) {
        error = ex;
    }
    assertNotNull(error);
    SerializableException sError = new SerializableException(error);
    ByteBuffer buffer = sError.serializeToBuffer();
    buffer.rewind();
    
    ShutdownPrepareRequest.Builder builder = ShutdownPrepareRequest.newBuilder()
                                                    .setSenderSite(0)
                                                    .setError(ByteString.copyFrom(buffer));
    ShutdownPrepareRequest request = builder.build();
    
    assertTrue(request.hasError());
    buffer = request.getError().asReadOnlyByteBuffer();
    SerializableException clone = SerializableException.deserializeFromBuffer(buffer);
    assertTrue(clone.getMessage(), clone.getMessage().contains(errorMsg));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:28,代码来源:TestHStoreCoordinator.java

示例2: prepareShutdownCluster

import org.voltdb.exceptions.SerializableException; //导入方法依赖的package包/类
protected void prepareShutdownCluster(final Throwable error) throws Exception {
    final CountDownLatch latch = new CountDownLatch(this.num_sites-1);
    
    if (this.num_sites > 1) {
        RpcCallback<ShutdownPrepareResponse> callback = new ShutdownPrepareCallback(this.num_sites, latch);
        ShutdownPrepareRequest.Builder builder = ShutdownPrepareRequest.newBuilder()
                                                    .setSenderSite(this.catalog_site.getId());
        // Pack the error into a SerializableException
        if (error != null) {
            SerializableException sError = new SerializableException(error);
            ByteBuffer buffer = sError.serializeToBuffer();
            buffer.rewind();
            builder.setError(ByteString.copyFrom(buffer));
            if (debug.val)
                LOG.debug("Serializing error message in shutdown request");
        }
        ShutdownPrepareRequest request = builder.build();
        
        if (debug.val)
            LOG.debug(String.format("Sending %s to %d remote sites",
                      request.getClass().getSimpleName(), this.num_sites-1));
        for (int site_id = 0; site_id < this.num_sites; site_id++) {
            if (site_id == this.local_site_id) continue;
            
            if (this.channels[site_id] == null) {
                LOG.error(String.format("Trying to send %s to %s before the connection was established",
                          request.getClass().getSimpleName(),
                          HStoreThreadManager.formatSiteName(site_id)));
            } else {
                this.channels[site_id].shutdownPrepare(new ProtoRpcController(), request, callback);
                if (trace.val)
                    LOG.trace(String.format("Sent %s to %s",
                              request.getClass().getSimpleName(),
                              HStoreThreadManager.formatSiteName(site_id)));
            }
        } // FOR
    }
    
    // Tell ourselves to get ready
    this.hstore_site.prepareShutdown(error != null);
    
    // Block until the latch releases us
    if (this.num_sites > 1) {
        LOG.info(String.format("Waiting for %d sites to finish shutting down", latch.getCount()));
        boolean result = latch.await(10, TimeUnit.SECONDS);
        if (result == false) {
            LOG.warn("Failed to recieve all shutdown responses");
        }
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:51,代码来源:HStoreCoordinator.java


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