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


Java NodeProbe.close方法代码示例

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


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

示例1: executeDescribe

import org.apache.cassandra.tools.NodeProbe; //导入方法依赖的package包/类
private void executeDescribe(Tree statement) throws TException, InvalidRequestException, NotFoundException
{
    if (!CliMain.isConnected())
        return;

    printCQL3TablesWarning("describe");

    int argCount = statement.getChildCount();

    if (keySpace == null && argCount == 0)
    {
        sessionState.out.println("Authenticate to a Keyspace, before using `describe` or `describe <column_family>`");
        return;
    }

    KsDef currentKeySpace = null;
    if (keySpace != null)
    {
        keyspacesMap.remove(keySpace);
        currentKeySpace = getKSMetaData(keySpace);
    }

    if (argCount > 1) // in case somebody changes Cli grammar
        throw new RuntimeException("`describe` command take maximum one argument. See `help describe;`");

    if (argCount == 0)
    {
        if (currentKeySpace != null)
        {
            describeKeySpace(currentKeySpace.name, null);
            return;
        }

        sessionState.out.println("Authenticate to a Keyspace, before using `describe` or `describe <column_family>`");
    }
    else if (argCount == 1)
    {
        // name of the keyspace or ColumnFamily
        String entityName = statement.getChild(0).getText();

        KsDef inputKsDef = CliUtils.getKeySpaceDef(entityName, thriftClient.describe_keyspaces());

        if (inputKsDef == null && currentKeySpace == null)
            throw new RuntimeException(String.format("Keyspace with name '%s' wasn't found, " +
                                                     "to lookup ColumnFamily with that name, please, authorize to one " +
                                                     "of the keyspaces first.", entityName));

        CfDef inputCfDef = (inputKsDef == null)
                ? getCfDef(currentKeySpace, entityName, false)
                : null;  // no need to lookup CfDef if we know that it was keyspace

        if (inputKsDef != null)
        {
            describeKeySpace(inputKsDef.name, inputKsDef);
        }
        else if (inputCfDef != null)
        {
            NodeProbe probe = sessionState.getNodeProbe();

            try
            {
                describeColumnFamily(currentKeySpace, inputCfDef, probe);

                if (probe != null)
                    probe.close();
            }
            catch (IOException e)
            {
                sessionState.out.println("Error while closing JMX connection: " + e.getMessage());
            }
        }
        else
        {
            sessionState.out.println("Sorry, no Keyspace nor (non-CQL3) ColumnFamily was found with name: " + entityName + " (if this is a CQL3 table, you should use cqlsh instead)");
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:78,代码来源:CliClient.java

示例2: executeDescribe

import org.apache.cassandra.tools.NodeProbe; //导入方法依赖的package包/类
private void executeDescribe(Tree statement) throws TException, InvalidRequestException, NotFoundException
{
    if (!CliMain.isConnected())
        return;

    printCQL3TablesWarning("describe");

    int argCount = statement.getChildCount();

    if (keySpace == null && argCount == 0)
    {
        sessionState.out.println("Authenticate to a Keyspace, before using `describe` or `describe <column_family>`");
        return;
    }

    KsDef currentKeySpace = null;
    if (keySpace != null)
    {
        keyspacesMap.remove(keySpace);
        currentKeySpace = getKSMetaData(keySpace);
    }

    if (argCount > 1) // in case somebody changes Cli grammar
        throw new RuntimeException("`describe` command take maximum one argument. See `help describe;`");

    if (argCount == 0)
    {
        if (currentKeySpace != null)
        {
            describeKeySpace(currentKeySpace.name, null);
            return;
        }

        sessionState.out.println("Authenticate to a Keyspace, before using `describe` or `describe <column_family>`");
    }
    else if (argCount == 1)
    {
        // name of the keyspace or ColumnFamily
        String entityName = statement.getChild(0).getText();

        KsDef inputKsDef = CliUtils.getKeySpaceDef(entityName, thriftClient.describe_keyspaces());

        if (inputKsDef == null && currentKeySpace == null)
            throw new RuntimeException(String.format("Keyspace with name '%s' wasn't found, " +
                                                     "to lookup ColumnFamily with that name, please, authorize to one " +
                                                     "of the keyspaces first.", entityName));

        CfDef inputCfDef = (inputKsDef == null)
                ? getCfDef(currentKeySpace, entityName)
                : null;  // no need to lookup CfDef if we know that it was keyspace

        if (inputKsDef != null)
        {
            describeKeySpace(inputKsDef.name, inputKsDef);
        }
        else if (inputCfDef != null)
        {
            NodeProbe probe = sessionState.getNodeProbe();

            try
            {
                describeColumnFamily(currentKeySpace, inputCfDef, probe);

                if (probe != null)
                    probe.close();
            }
            catch (IOException e)
            {
                sessionState.out.println("Error while closing JMX connection: " + e.getMessage());
            }
        }
        else
        {
            sessionState.out.println("Sorry, no Keyspace nor ColumnFamily was found with name: " + entityName);
        }
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:78,代码来源:CliClient.java


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