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


Java ClientImpl类代码示例

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


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

示例1: execute

import org.voltdb.client.ClientImpl; //导入依赖的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,项目名称:sstore-soft,代码行数:33,代码来源:JDBC4ClientConnection.java

示例2: executeAsync

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
/**
 * Executes a procedure asynchronously, returning a Future that can be used by the caller to
 * wait upon completion before processing the server response.
 *
 * @param procedure
 *            the name of the procedure to call.
 * @param parameters
 *            the list of parameters to pass to the procedure.
 * @return the Future created to wrap around the asynchronous process.
 */
public Future<ClientResponse> executeAsync(String procedure, Object... parameters)
        throws NoConnectionsException, IOException
{
    ClientImpl currentClient = this.getClient();
    final JDBC4ExecutionFuture future = new JDBC4ExecutionFuture(this.defaultAsyncTimeout);
    try {
        currentClient.callProcedure(new TrackingCallback(this, procedure, new ProcedureCallback() {
            @SuppressWarnings("unused")
            final JDBC4ExecutionFuture result;
            {
                this.result = future;
            }

            @Override
            public void clientCallback(ClientResponse response) { 
                future.set(response);
            }
        }), procedure, parameters);
    }
    catch (NoConnectionsException e) {
        this.dropClient(currentClient);
        throw e;
    }
    return future;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:36,代码来源:JDBC4ClientConnection.java

示例3: execute

import org.voltdb.client.ClientImpl; //导入依赖的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 {
    long start = System.currentTimeMillis();
    ClientImpl currentClient = this.getClient();
    try {
        // If connections are lost try reconnecting.
        ClientResponse response = currentClient.callProcedureWithTimeout(procedure, timeout, TimeUnit.SECONDS, parameters);
        return response;
    }
    catch (ProcCallException pce) {
        throw pce;
    }
    catch (NoConnectionsException e) {
        this.dropClient(currentClient);
        throw e;
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:31,代码来源:JDBC4ClientConnection.java

示例4: executeAsync

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
/**
 * Executes a procedure asynchronously, returning a Future that can be used by the caller to
 * wait upon completion before processing the server response.
 *
 * @param procedure
 *            the name of the procedure to call.
 * @param parameters
 *            the list of parameters to pass to the procedure.
 * @return the Future created to wrap around the asynchronous process.
 */
public Future<ClientResponse> executeAsync(String procedure, Object... parameters)
        throws NoConnectionsException, IOException
{
    ClientImpl currentClient = this.getClient();
    final JDBC4ExecutionFuture future = new JDBC4ExecutionFuture(this.defaultAsyncTimeout);
    try {
        currentClient.callProcedure(new TrackingCallback(this, procedure, new ProcedureCallback() {
            @SuppressWarnings("unused")
            final JDBC4ExecutionFuture result;
            {
                this.result = future;
            }

            @Override
            public void clientCallback(ClientResponse response) throws Exception {
                future.set(response);
            }
        }), procedure, parameters);
    }
    catch (NoConnectionsException e) {
        this.dropClient(currentClient);
        throw e;
    }
    return future;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:36,代码来源:JDBC4ClientConnection.java

示例5: PerPartitionTable

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
PerPartitionTable(ClientImpl clientImpl, String tableName, int partitionId, boolean isMP,
        VoltBulkLoader firstLoader, int minBatchTriggerSize) {
    m_clientImpl = clientImpl;
    m_partitionId = partitionId;
    m_isMP = isMP;
    m_procName = firstLoader.m_procName;
    m_partitionRowQueue = new LinkedBlockingQueue<VoltBulkLoaderRow>(minBatchTriggerSize*5);
    m_minBatchTriggerSize = minBatchTriggerSize;
    m_columnInfo = firstLoader.m_colInfo;
    m_partitionedColumnIndex = firstLoader.m_partitionedColumnIndex;
    m_columnTypes = firstLoader.m_columnTypes;
    m_partitionColumnType = firstLoader.m_partitionColumnType;
    m_tableName = tableName;

    table = new VoltTable(m_columnInfo);

    m_es = CoreUtils.getSingleThreadExecutor(tableName + "-" + partitionId);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:19,代码来源:PerPartitionTable.java

示例6: connectionLost

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
@Override
public void connectionLost(String hostname, int port, int connectionsLeft, DisconnectCause cause) {
        log.warn(_F("Lost connection to %s:%d.", hostname, port));
        totalConnections.decrementAndGet();

        // reset the connection id so the client will connect to a recovered cluster
        // this is a bit of a hack
        if (connectionsLeft == 0) {
            ((ClientImpl) client).resetInstanceId();
        }

        // setup for retry
        final String server = MiscUtils.getHostnameColonPortString(hostname, port);
        class ReconnectThread extends Thread {
            @Override
            public void run() {
                connectToOneServerWithRetry(server);
            }
        };

        ReconnectThread th = new ReconnectThread();
        th.setDaemon(true);
        th.start();
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:25,代码来源:SchemaChangeClient.java

示例7: tryValidDDL

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
private void tryValidDDL(ClientImpl client) throws Exception
{
    validDDLAttempt++;
    String tableName = String.format("FOO%d", validDDLAttempt);
    String ddl = String.format("create table %s (id smallint not null);", tableName);
    try {
        ClientResponse resp2 = client.callProcedureWithTimeout("@AdHoc", 20, TimeUnit.SECONDS, ddl);
        assertTrue(String.format("Valid DDL attempt #%d failed.", validDDLAttempt),
                   resp2.getStatus() == ClientResponse.SUCCESS);
    }
    catch(ProcCallException pce2) {
        fail("Valid DDL from new client failed with exception after previous one had exception. "
                + pce2.getLocalizedMessage());
    }
    assertTrue(String.format("Failed to create table %s.", tableName),
               findTableInSystemCatalogResults(tableName));
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:18,代码来源:TestAdhocCompilerException.java

示例8: dropClient

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
/**
 * Drop the client connection, e.g. when a NoConnectionsException is caught.
 * It will try to reconnect as needed and appropriate.
 * @param clientToDrop caller-provided client to avoid re-nulling from another thread that comes in later
 */
protected synchronized void dropClient(ClientImpl clientToDrop) {
    Client currentClient = this.client.get();
    if (currentClient != null && currentClient == clientToDrop) {
        try {
            currentClient.close();
            this.client.set(null);
        }
        catch (Exception x) {
            // ignore
            LOG.error("JDBC client failed to close self", (debug.val ? x : null));
        }
    }
    this.users = 0;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:20,代码来源:JDBC4ClientConnection.java

示例9: backpressureBarrier

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
/**
 * Blocks the current thread until there is no more backpressure or there are no more
 * connections to the database
 *
 * @throws InterruptedException
 * @throws IOException
 */
public void backpressureBarrier() throws InterruptedException, IOException {
    ClientImpl currentClient = this.getClient();
    if (currentClient == null) {
        throw new IOException("Client is unavailable for backpressureBarrier().");
    }
    currentClient.backpressureBarrier();
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:15,代码来源:JDBC4ClientConnection.java

示例10: dropClient

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
/**
 * Drop the client connection, e.g. when a NoConnectionsException is caught.
 * It will try to reconnect as needed and appropriate.
 * @param clientToDrop caller-provided client to avoid re-nulling from another thread that comes in later
 */
protected synchronized void dropClient(ClientImpl clientToDrop) {
    Client currentClient = this.client.get();
    if (currentClient != null && currentClient == clientToDrop) {
        try {
            currentClient.close();
            this.client.set(null);
        }
        catch (Exception x) {
            // ignore
        }
    }
    this.users = 0;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:19,代码来源:JDBC4ClientConnection.java

示例11: CSVTupleDataLoader

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
public CSVTupleDataLoader(ClientImpl client, String procName, BulkLoaderErrorHandler errHandler)
        throws IOException, ProcCallException
{
    m_client = client;
    m_insertProcedure = procName;
    m_errHandler = errHandler;

    List<VoltType> typeList = Lists.newArrayList();
    VoltTable procInfo = client.callProcedure("@SystemCatalog", "PROCEDURECOLUMNS").getResults()[0];
    while (procInfo.advanceRow()) {
        if (m_insertProcedure.equalsIgnoreCase(procInfo.getString("PROCEDURE_NAME"))) {
            String typeStr = (String) procInfo.get("TYPE_NAME", VoltType.STRING);
            typeList.add(VoltType.typeFromString(typeStr));
        }
    }
    if (typeList.isEmpty()) {
        //csvloader will exit
        throw new RuntimeException("No matching insert procedure available");
    }
    m_columnTypes = typeList.toArray(new VoltType[0]);

    int sleptTimes = 0;
    while (!client.isHashinatorInitialized() && sleptTimes < 120) {
        try {
            Thread.sleep(500);
            sleptTimes++;
        } catch (InterruptedException ex) {}
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:30,代码来源:CSVTupleDataLoader.java

示例12: processKafkaMessages

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
public void processKafkaMessages() throws Exception {
    // Split server list
    final String[] serverlist = m_config.servers.split(",");

    // Create connection
    final ClientConfig c_config = new ClientConfig(m_config.user, m_config.password);
    c_config.setProcedureCallTimeout(0); // Set procedure all to infinite

    m_client = getClient(c_config, serverlist, m_config.port);

    if (m_config.useSuppliedProcedure) {
        m_loader = new CSVTupleDataLoader((ClientImpl) m_client, m_config.procedure, new KafkaBulkLoaderCallback());
    } else {
        m_loader = new CSVBulkDataLoader((ClientImpl) m_client, m_config.table, m_config.batch, new KafkaBulkLoaderCallback());
    }
    m_loader.setFlushInterval(m_config.flush, m_config.flush);
    m_consumer = new KafkaConsumerConnector(m_config.zookeeper, m_config.useSuppliedProcedure ? m_config.procedure : m_config.table);
    try {
        m_es = getConsumerExecutor(m_consumer, m_loader);
        if (m_config.useSuppliedProcedure) {
            m_log.info("Kafka Consumer from topic: " + m_config.topic + " Started using procedure: " + m_config.procedure);
        } else {
            m_log.info("Kafka Consumer from topic: " + m_config.topic + " Started for table: " + m_config.table);
        }
        m_es.awaitTermination(365, TimeUnit.DAYS);
    } catch (Exception ex) {
        m_log.error("Error in Kafka Consumer", ex);
        System.exit(-1);
    }
    close();
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:32,代码来源:KafkaLoader.java

示例13: connectionLost

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
/**
 * Remove the client from the list if connection is broken.
 */
@Override
public void connectionLost(String hostname, int port, int connectionsLeft, DisconnectCause cause) {
    if (shutdown.get()) {
        return;
    }

    activeConnections.decrementAndGet();

    // reset the connection id so the client will connect to a recovered cluster
    // this is a bit of a hack
    if (connectionsLeft == 0) {
        ((ClientImpl) client).resetInstanceId();
    }

    // if the benchmark is still active
    if ((System.currentTimeMillis() - benchmarkStartTS) < (config.duration * 1000)) {
        log.warn(String.format("Connection to %s:%d was lost.", hostname, port));
    }

    // setup for retry
    final String server = MiscUtils.getHostnameColonPortString(hostname, port);
    es.execute(new Runnable() {
        @Override
        public void run() {
            connectToOneServerWithRetry(server);
        }
    });
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:32,代码来源:Benchmark.java

示例14: nextPartitionKey

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
private String nextPartitionKey(String key) throws NoConnectionsException, IOException, ProcCallException
{
    if (m_partitionkeys == null)
    {
        initializePartitionKeys();
    }
    long nextPartition = ((ClientImpl) m_client).getPartitionForParameter(VoltType.STRING.getValue(), key) + 1;
    if (nextPartition >= m_partitionkeys.length)
    {
       return null;
    }
    return m_partitionkeys[(int) nextPartition];
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:14,代码来源:VoltClient4.java

示例15: initializePartitionKeys

import org.voltdb.client.ClientImpl; //导入依赖的package包/类
private void initializePartitionKeys() throws NoConnectionsException, IOException, ProcCallException
{
    VoltTable keyTables = m_client.callProcedure("@GetPartitionKeys", "STRING").getResults()[0];
    m_partitionkeys = new String[keyTables.getRowCount()];
    while (keyTables.advanceRow())
    {
        String partkey = keyTables.getString(1);
        int partition = (int) ((ClientImpl) m_client).getPartitionForParameter(VoltType.STRING.getValue(), partkey);
        m_partitionkeys[partition] = partkey;
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:12,代码来源:VoltClient4.java


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