• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ClientResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getResult

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
private VoltTable getResult(Client client, String procName) throws Exception 
{
    VoltTable result = null;
    
    Procedure catalog_proc = runner.catalog_db.getProcedures().getIgnoreCase(procName);
    if (catalog_proc == null) {
        throw new Exception("Invalid stored procedure name '" + procName + "'");
    }
    
    //result = client.asynCallProcedure(null, catalog_proc.getName(), null, params);
    ClientResponse response = client.callProcedure(catalog_proc.getName());
    
    if(response.getStatus()==Status.OK)
    {
        result = response.getResults()[0];
    }
    else
        System.out.println("Failed : " + catalog_proc.getName());
    
    return result;
}
 
开发者ID:s-store,项目名称:s-store,代码行数:22,代码来源:BatchRunner.java


示例2: testGetNewDestination

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
 * testGetNewDestination
 */
public void testGetNewDestination() throws Exception {
    Client client = this.getClient();
    RegressionSuiteUtil.initializeTM1Database(this.getCatalogContext(), client);
    TM1Client.Transaction txn = Transaction.DELETE_CALL_FORWARDING;
    Object params[] = txn.generateParams(NUM_SUBSCRIBERS);
    ClientResponse cresponse = null;
    try {
        cresponse = client.callProcedure(txn.callName, params);
        assertEquals(Status.OK, cresponse.getStatus());
    } catch (ProcCallException ex) {
        cresponse = ex.getClientResponse();
        assertEquals(cresponse.toString(), Status.ABORT_USER, cresponse.getStatus());
    }
    assertNotNull(cresponse);
    assertTrue(cresponse.toString(), cresponse.isSinglePartition());
}
 
开发者ID:s-store,项目名称:s-store,代码行数:20,代码来源:TestTM1Suite.java


示例3: testDeleteCallForwarding

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
     * testDeleteCallForwarding
     */
    public void testDeleteCallForwarding() throws Exception {
        Client client = this.getClient();
        RegressionSuiteUtil.initializeTM1Database(this.getCatalogContext(), client);
        TM1Client.Transaction txn = Transaction.DELETE_CALL_FORWARDING;
        Object params[] = txn.generateParams(NUM_SUBSCRIBERS);
        
        for (int i = 0; i < 1000; i++) {
            ClientResponse cresponse = null;
            try {
                cresponse = client.callProcedure(txn.callName, params);
                assertEquals(Status.OK, cresponse.getStatus());
            } catch (ProcCallException ex) {
                cresponse = ex.getClientResponse();
//                System.err.println();
                assertEquals(cresponse.toString(), Status.ABORT_USER, cresponse.getStatus());
            }
            assertNotNull(cresponse);
        } // FOR
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:23,代码来源:TestTM1Suite.java


示例4: execute

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
 * Executes a procedure synchronously and returns the result to the caller. The method
 * internally tracks execution performance.
 *
 * @param procedure
 *            the name of the procedure to call.
 * @param parameters
 *            the list of parameters to pass to the procedure.
 * @return the response sent back by the VoltDB cluster for the procedure execution.
 * @throws IOException
 * @throws NoConnectionsException
 * @throws ProcCallException
 */
public ClientResponse execute(String procedure, long timeout, Object... parameters)
        throws NoConnectionsException, IOException, ProcCallException {
    ClientImpl currentClient = this.getClient();
    try {
        // If connections are lost try reconnecting.
    	ClientResponse response = currentClient.callProcedure(procedure, parameters);
    	if (trace.val) {
    	    LOG.trace(String.format("JDBC client executed qury %s", procedure));
    	}
    	return response;
    }
    catch (ProcCallException pce) {
        throw pce;
    }
    catch (NoConnectionsException e) {
        this.dropClient(currentClient);
        throw e;
    }
}
 
开发者ID:s-store,项目名称:s-store,代码行数:33,代码来源:JDBC4ClientConnection.java


示例5: clientCallbackImpl

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
@Override
public void clientCallbackImpl(ClientResponse clientResponse) {
    if (clientResponse.getStatus() == Status.OK) {
        // We can remove this from our set of full flights because know that there is now a free seat
        BitSet seats = getSeatsBitSet(element.flight_id);
        seats.set(element.seatnum, false);
        
        // And then put it up for a pending insert
        if (rng.nextInt(100) < SEATSConstants.PROB_REQUEUE_DELETED_RESERVATION) {
            Buffer<Reservation> cache = CACHE_RESERVATIONS.get(CacheType.PENDING_INSERTS);
            assert(cache != null) : "Unexpected " + CacheType.PENDING_INSERTS;
            synchronized (cache) {
                cache.add(element);
            } // SYNCH
        }
    } else if (debug.val) {
        LOG.info("DeleteReservation " + clientResponse.getStatus() + ": " + clientResponse.getStatusString(), clientResponse.getException());
        LOG.info("BUSTED ID: " + element.flight_id + " / " + element.flight_id);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:21,代码来源:SEATSClient.java


示例6: testInitialize

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
 * testInitialize
 */
public void testInitialize() throws Exception {
    Client client = this.getClient();
    RegressionSuiteUtil.initializeTPCCDatabase(this.getCatalogContext(), client);
    
    String procName = VoltSystemProcedure.procCallName(AdHoc.class);
    for (String tableName : TPCCConstants.TABLENAMES) {
        String query = "SELECT COUNT(*) FROM " + tableName;
        ClientResponse cresponse = client.callProcedure(procName, query);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        long count = results[0].asScalarLong();
        assertTrue(tableName + " -> " + count, count > 0);
        // System.err.println(tableName + "\n" + VoltTableUtil.format(results[0]));
    } // FOR
}
 
开发者ID:s-store,项目名称:s-store,代码行数:20,代码来源:TestMarkovSuite.java


示例7: testTupleAccessCountNoIndex

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
 * testTupleAccessCountNoIndex
 */
public void testTupleAccessCountNoIndex() throws Exception {
    CatalogContext catalogContext = this.getCatalogContext();
    Client client = this.getClient();
    RegressionSuiteUtil.initializeTPCCDatabase(catalogContext, client);
    
    ClientResponse cresponse = RegressionSuiteUtil.getStats(client, SysProcSelector.TABLE);
    assertNotNull(cresponse);
    assertEquals(Status.OK, cresponse.getStatus());
    this.checkTupleAccessCount(TPCCConstants.TABLENAME_ITEM, cresponse.getResults()[0], 0);
    
    int expected = 20;
    for (int i = 0; i < expected; i++) {
        cresponse = client.callProcedure("GetItemNoIndex");
        assertNotNull(cresponse);
        assertEquals(Status.OK, cresponse.getStatus());
    } // FOR
    
    cresponse = RegressionSuiteUtil.getStats(client, SysProcSelector.TABLE);
    assertNotNull(cresponse);
    assertEquals(Status.OK, cresponse.getStatus());
    this.checkTupleAccessCount(TPCCConstants.TABLENAME_ITEM, cresponse.getResults()[0], expected);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:26,代码来源:TestStatsSuite.java


示例8: checkBalance

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
public static void checkBalance(Client client, long acctId, double expected) throws Exception {
    // Make sure that we set it correctly
    String query = String.format("SELECT * FROM %s WHERE custid = %d",
                          SmallBankConstants.TABLENAME_CHECKING, acctId);
    ClientResponse cresponse = client.callProcedure("@AdHoc", query);
    assertEquals(Status.OK, cresponse.getStatus());
    VoltTable results[] = cresponse.getResults();
    assertEquals(1, results.length);
    
    if (results[0].getRowCount() == 0) {
        System.err.println(VoltTableUtil.format(results[0]));
    }
    assertEquals("No rows for acctId "+acctId, 1, results[0].getRowCount());
    assertTrue(results[0].advanceRow());
    assertEquals("Mismatched balance for acctId "+acctId, expected, results[0].getDouble("bal"));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:17,代码来源:TestSmallBankSuite.java


示例9: testInitialize

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
 * testInitialize
 */
public void testInitialize() throws Exception {
    Client client = this.getClient();
    this.initWikipediaDatabase(this.getCatalogContext(), client);
    
    Set<String> allTables = new HashSet<String>();
    
    String procName = VoltSystemProcedure.procCallName(AdHoc.class);
    for (String tableName : allTables) {
        String query = "SELECT COUNT(*) FROM " + tableName;
        ClientResponse cresponse = client.callProcedure(procName, query);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        long count = results[0].asScalarLong();
        assertTrue(tableName + " -> " + count, count > 0);
        // System.err.println(tableName + "\n" + results[0]);
    } // FOR
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:22,代码来源:TestWikipediaSuite.java


示例10: clientCallback

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
@Override
public void clientCallback(ClientResponse clientResponse) {
    if (clientResponse.getStatus() != Status.OK){
        System.out.println(clientResponse.getStatusString());
        System.out.println(clientResponse.getException());
        System.exit(-1);
    }
    incrementTransactionCounter(clientResponse, 0);
    final VoltTable vt = clientResponse.getResults()[0];
    if (!vt.advanceRow()) {
        System.err.println("No rows returned by SelectBlob");
        System.exit(-1);
    }
    final byte bytes[] = vt.getStringAsBytes(1);
    if (bytes.length != m_blobSize) {
        System.err.println("Returned blob size was not correct. Expected "
                + m_blobSize + " but got " + bytes.length);
        System.exit(-1);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:21,代码来源:BlobTortureClient.java


示例11: getResult

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
private VoltTable getResult(Client client, String procName) throws Exception 
{
    VoltTable result = null;
    
    Procedure catalog_proc = this.catalog_db.getProcedures().getIgnoreCase(procName);
    if (catalog_proc == null) {
        throw new Exception("Invalid stored procedure name '" + procName + "'");
    }
    
    //result = client.asynCallProcedure(null, catalog_proc.getName(), null, params);
    ClientResponse response = client.callProcedure(catalog_proc.getName());
    
    if(response.getStatus()==Status.OK)
    {
        result = response.getResults()[0];
    }
    else
        System.out.println("Failed : " + catalog_proc.getName());
    
    return result;
}
 
开发者ID:s-store,项目名称:s-store,代码行数:22,代码来源:BatchRunner.java


示例12: testTABLECOUNTS

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
public void testTABLECOUNTS() throws IOException, ProcCallException {
    Client client = getClient();
    ClientResponse cr = null;
    CatalogContext catalogContext = this.getCatalogContext();
    
    Random rand = this.getRandom();
    int num_tuples = 11;
    for (Table catalog_tbl : catalogContext.database.getTables()) {
        RegressionSuiteUtil.loadRandomData(client, catalog_tbl, rand, num_tuples);
    } // FOR (table)
    
    // Now get the counts for the tables that we just loaded
    cr = client.callProcedure(GetTableCounts.class.getSimpleName());
    // System.err.println(cr);
    assertEquals(Status.OK, cr.getStatus());
    assertEquals(1, cr.getResults().length);
    VoltTable vt = cr.getResults()[0];
    while (vt.advanceRow()) {
        String tableName = vt.getString(0);
        int count = (int)vt.getLong(1);
        assertEquals(tableName, num_tuples, count);
    } // WHILE
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:24,代码来源:TestTPCCSuite.java


示例13: testMultiPartitionTxn

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
     * testMultiPartitionTxn
     */
    @Test
    public void testMultiPartitionTxn() throws Exception {
        this.loadData(this.getTable(TM1Constants.TABLENAME_SUBSCRIBER));
        this.loadData(this.getTable(TM1Constants.TABLENAME_CALL_FORWARDING));
        
        // Simple test to check whether we can execute multi-partition txns serially
        Procedure catalog_proc = this.getProcedure(DeleteCallForwarding.class);
        for (int i = 0; i < NUM_TXNS; i++) {
            Object params[] = { Integer.toString(i), 1l, 1l };
            ClientResponse cr = this.client.callProcedure(catalog_proc.getName(), params);
            assertEquals(Status.OK, cr.getStatus());
        }
//        System.err.println(cr);
        this.statusSnapshot();
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:19,代码来源:TestHStoreSite.java


示例14: testVoteLimit

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
 * testVoteLimit
 */
public void testVoteLimit() throws Exception {
    Client client = this.getClient();
    this.initializeDatabase(client);
    
    // Make sure that the phone number is only allowed to vote up to
    // the limit and not anymore after that
    ClientResponse cresponse = null;
    for (int i = 0, cnt = (int)(maxVotesPerPhoneNumber*2); i < cnt; i++) {
        long expected = (i < maxVotesPerPhoneNumber ? VoterConstants.VOTE_SUCCESSFUL :
                                                      VoterConstants.ERR_VOTER_OVER_VOTE_LIMIT);
        cresponse = client.callProcedure(Vote.class.getSimpleName(),
                                         voteId++,
                                         phoneNumber,
                                         contestantNumber,
                                         maxVotesPerPhoneNumber);
        assertEquals(Status.OK, cresponse.getStatus());
        VoltTable results[] = cresponse.getResults();
        assertEquals(1, results.length);
        //assertEquals(expected, results[0].asScalarLong());
    } // FOR
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:25,代码来源:TestVoterSuite.java


示例15: hasTuple

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
private boolean hasTuple(String streamName)
{
    boolean result = false;
    
    try{
        
        Client client = ClientFactory.createClient(128, null, false, null);
        String hostname;
        int port;
        hostname = catalog_site.getHost().getIpaddr();
        port = catalog_site.getProc_port();

        client.createConnection(null, hostname, port, "user", "password");
        String query = "select * from " + streamName;
        ClientResponse cresponse = client.callProcedure("@AdHoc", query);
            
        if (cresponse != null) {
            if (cresponse.getStatus() == Status.OK) {
                LOG.info(streamName + " - " + this.formatResult(cresponse));  
                VoltTable results[] = cresponse.getResults();
                if(results[0].getRowCount() != 0)
                    result = true;
            } else {
                System.out.printf("Server Response: %s / %s\n",
                                  cresponse.getStatus(),
                                  cresponse.getStatusString());
            }
        }
        
        client.close();
    }
    catch (Exception ex) {
        ex.printStackTrace();
    }
    
    return result;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:38,代码来源:HStoreSite.java


示例16: testUpdateLocation

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
 * testUpdateLocation
 */
public void testUpdateLocation() throws Exception {
    Client client = this.getClient();
    RegressionSuiteUtil.initializeTM1Database(this.getCatalogContext(), client);
    TM1Client.Transaction txn = Transaction.UPDATE_LOCATION;
    Object params[] = txn.generateParams(NUM_SUBSCRIBERS);
    ClientResponse cresponse = client.callProcedure(txn.callName, params);
    assertNotNull(cresponse);
    assertEquals(Status.OK, cresponse.getStatus());
}
 
开发者ID:s-store,项目名称:s-store,代码行数:13,代码来源:TestTM1Suite.java


示例17: checkTransaction

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
/**
 * Performs constraint checking on the result set in clientResponse. It does
 * simple sanity checks like if the response code is SUCCESS. If the check
 * transaction flag is set to true by calling setCheckTransaction(), then it
 * will check the result set against constraints.
 *
 * @param procName
 *            The name of the procedure
 * @param clientResponse
 *            The client response
 * @param errorExpected
 *            true if the response is expected to be an error.
 * @return true if it passes all tests, false otherwise
 */
protected boolean checkTransaction(String procName,
                                   ClientResponse clientResponse,
                                   boolean abortExpected,
                                   boolean errorExpected) {
    final Status status = clientResponse.getStatus();
  //  System.out.println(status);
    if (status != Status.OK) {
        if (errorExpected)
            return true;

        if (abortExpected && status == Status.ABORT_USER)
            return true;

        if (status == Status.ABORT_CONNECTION_LOST) {
            return false;
        }
        if (status == Status.ABORT_REJECT) {
            return false;
        }

        if (clientResponse.getException() != null) {
            clientResponse.getException().printStackTrace();
        }
        if (clientResponse.getStatusString() != null) {
            LOG.warn(clientResponse.getStatusString());
        }
        throw new RuntimeException("Invalid " + procName + " response!\n" + clientResponse);
    }

    if (m_checkGenerator.nextFloat() >= m_checkTransaction)
        return true;

    return checkConstraints(procName, clientResponse);
}
 
开发者ID:s-store,项目名称:s-store,代码行数:49,代码来源:BenchmarkComponent.java


示例18: clientCallback

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
@Override
public void clientCallback(ClientResponse clientResponse) {
    final Status status = clientResponse.getStatus();
    if (status != Status.OK) {
        if (status == Status.ABORT_CONNECTION_LOST){
            /*
             * Status of the last transaction involving the tournament
             * is unknown it could have committed. Recovery code would
             * go here.
             */
            return;
        }

        if (clientResponse.getException() != null) {
            clientResponse.getException().printStackTrace();
        }
        if (debug.val && clientResponse.getStatusString() != null) {
            LOG.warn(clientResponse.getStatusString());
        }
        return;
    }
    synchronized (tournaments) {
        tournaments.offer(Tourney.this);
        tournaments.notifyAll();
    }
    incrementTransactionCounter(clientResponse, t.ordinal());
}
 
开发者ID:s-store,项目名称:s-store,代码行数:28,代码来源:BingoClient.java


示例19: formatResult

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
private String formatResult(ClientResponse cr) {
    final VoltTable results[] = cr.getResults();
    final int num_results = results.length;
    StringBuilder sb = new StringBuilder();
    
    if (this.enable_debug) {
        sb.append(cr.toString());
    }
    else {
        // MAIN BODY
        if (this.enable_csv) {
            StringWriter out = new StringWriter();
            for (int i = 0; i < num_results; i++) {
                if (i > 0) out.write("\n\n");
                VoltTableUtil.csv(out, results[i], true);
            } // FOR
            sb.append(out.toString());
        } else {
            sb.append(VoltTableUtil.format(results));
        }
        
        // FOOTER
        String footer = "";
        if (this.enable_csv == false) {
            if (num_results == 1) {
                int row_count = results[0].getRowCount(); 
                footer = String.format("%d row%s in set", row_count, (row_count > 1 ? "s" : ""));
            }
            else if (num_results == 0) {
                footer = "No results returned";
            }
            else {
                footer = num_results + " tables returned";
            }
            sb.append(String.format("\n%s (%.2f sec)\n", footer, (cr.getClientRoundtrip() / 1000d)));
        }
    }
    return (sb.toString());
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:40,代码来源:HStoreTerminal.java


示例20: clientCallback

import org.voltdb.client.ClientResponse; //导入依赖的package包/类
@Override
public void clientCallback(ClientResponse clientResponse) {
    final Status status = clientResponse.getStatus();
    incrementTransactionCounter(clientResponse, 0);

    if (status != Status.OK) {
        System.err.println("Failed to execute!!!");
        System.err.println(clientResponse.getException());
        System.err.println(clientResponse.getStatusString());
        System.exit(-1);
    } else {
        pClientCallback(clientResponse.getResults());
    }
}
 
开发者ID:s-store,项目名称:s-store,代码行数:15,代码来源:ClientBenchmark.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Robolectric类代码示例发布时间:2022-05-23
下一篇:
Java JsonPathException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap