带有分区键的cassandra getendpoints有空间 [英] cassandra getendpoints with partition key has space

查看:334
本文介绍了带有分区键的cassandra getendpoints有空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的分区键是id(int)和name(text)。
下面的命令可以正常工作,直到名称(文本)中没有空格为止。
nodetool getendpoints test testtable2 1:aaa;

my partition keys are id(int) and name(text). Below command works fine until there is no space in name(text). nodetool getendpoints test testtable2 1:aaa;

如果正在使用
nodetool getendpoints test testtable2 3: aac cc;
会引发错误,因为: nodetool:getendpoints需要键空间,表和分区键参数
请参阅 nodetool帮助或 nodetool帮助。

if am using nodetool getendpoints test testtable2 3:aac cc; it throws an error as :nodetool: getendpoints requires keyspace, table and partition key arguments See 'nodetool help' or 'nodetool help '.

我通过执行
从test.testtable2中选择id,name,token(id,name)来获得令牌,其中name ='aac cc'AND id = 3;
并尝试搜索
nodetool getendpoints test testtable2 -7072928299163215694;
错误:对于输入字符串:-7072928299163215694
-StackTrace-
java.lang.NumberFormatException:对于输入字符串: -7072928299163215694

我如何搜索分区键(名称)是否有空间?

how can i search if partition key (name) has space?

推荐答案

这是 nodetool 命令。

我修改了 nodetool 脚本并创建了 getend points 脚本以支持带有分区键的getendpoints具有空间

I have modified the nodetool script and create getendpoints script to support getendpoints with partition key has space

这是 getendpoints 代码:

#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if [ "`basename "$0"`" = 'nodeprobe' ]; then
    echo "***************************************************************" >&2
    echo "WARNING: $0 is obsolete, use `dirname "$0"`/nodetool instead" >&2
    echo "***************************************************************" >&2
fi

if [ "x$CASSANDRA_INCLUDE" = "x" ]; then
    for include in "`dirname "$0"`/cassandra.in.sh" \
                   "$HOME/.cassandra.in.sh" \
                   /usr/share/cassandra/cassandra.in.sh \
                   /usr/local/share/cassandra/cassandra.in.sh \
                   /opt/cassandra/cassandra.in.sh; do
        if [ -r "$include" ]; then
            . "$include"
            break
        fi
    done
elif [ -r "$CASSANDRA_INCLUDE" ]; then
    . "$CASSANDRA_INCLUDE"
fi

# Use JAVA_HOME if set, otherwise look for java in PATH
if [ -x "$JAVA_HOME/bin/java" ]; then
    JAVA="$JAVA_HOME/bin/java"
else
    JAVA="`which java`"
fi

if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then
    echo "You must set the CASSANDRA_CONF and CLASSPATH vars" >&2
    exit 1
fi

# Run cassandra-env.sh to pick up JMX_PORT
if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then
    . "$CASSANDRA_CONF/cassandra-env.sh"
fi

# JMX Port passed via cmd line args (-p 9999 / --port 9999 / --port=9999)
# should override the value from cassandra-env.sh
ARGS=""
JVM_ARGS=""
SSL_FILE=$HOME/.cassandra/nodetool-ssl.properties
KS=""
CF=""
KEY=""

while true
do
  if [ ! $1 ]; then break; fi
  case $1 in
    -p)
      JMX_PORT=$2
      shift
      ;;
    --port=*)
      JMX_PORT=$(echo $1 | cut -d '=' -f 2)
      ;;
    --port)
      JMX_PORT=$2
      shift
      ;;
    --ssl)
      if [ -f $SSL_FILE ]
      then 
          SSL_ARGS=$(cat $SSL_FILE | tr '\n' ' ')
      fi
      JVM_ARGS="$JVM_ARGS -Dssl.enable=true $SSL_ARGS"
      ;;
    -D*)
      JVM_ARGS="$JVM_ARGS $1"
      ;;
    -k)
      KS=$2
      shift
      ;;
    -t)
      CF=$2
      shift
      ;;
    *)
      if [ ! $KEY ]; then 
    KEY="$1"
      else
    KEY="$KEY $1"
      fi
      ;;
  esac
  shift
done

# Special-case path variables.
case "`uname`" in
    CYGWIN*) 
        CLASSPATH="`cygpath -p -w "$CLASSPATH"`"
        CASSANDRA_CONF="`cygpath -p -w "$CASSANDRA_CONF"`"
    ;;
esac

"$JAVA" $JAVA_AGENT -cp "$CLASSPATH" \
      -Xmx128m \
      -Dcassandra.storagedir="$cassandra_storagedir" \
      -Dlogback.configurationFile=logback-tools.xml \
      -Dstorage-config="$CASSANDRA_CONF" \
      $JVM_ARGS \
      org.apache.cassandra.tools.NodeTool -p $JMX_PORT getendpoints $KS $CF "$KEY"

放入 getendpoints 文件,位于 $ CASSANDRA_HOME / bin 目录下。

Put getendpoints file under $CASSANDRA_HOME/bin directory.

现在您可以运行此文件带有nodetool参数的文件,以及下面的参数

Now you can run this file with nodetool argument,along with below argument

getendpoints -k keyspace_name -t table_name key

示例:

getendpoints -k test -t testtable2 3:aac cc

这篇关于带有分区键的cassandra getendpoints有空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆