小编dcd*_*cds的帖子

如何检查csh脚本中是否存在任何文件?

用于检查我正在使用的csh脚本中是否存在任何文件

if [ -f /var/opt/temip/conf/.temip_config ]
Run Code Online (Sandbox Code Playgroud)

但我得到低于错误

if [ -f /var/opt/temip/conf/.temip_config ]

if: Expression Syntax.
Run Code Online (Sandbox Code Playgroud)

谁能告诉我怎么做?

linux csh

8
推荐指数
2
解决办法
4万
查看次数

当集群中有 4 个代理中有 3 个代理时,kafka 主题创建失败

Kafka 主题创建在以下情况下失败:

节点为kafka集群:4

复制因子:4

集群中启动并运行的节点数:3

下面是错误:

./kafka-topics.sh --zookeeper :2181 --create --topic test_1 --partitions 1 --replication-factor 4
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Error while executing topic command : Replication factor: 4 larger than available brokers: 3.
[2018-10-31 11:58:13,084] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 4 larger than available brokers: 3.
Run Code Online (Sandbox Code Playgroud)

这是 kafka 中的有效行为还是某些已知问题?

如果集群中的所有节点都应该始终启动并运行,那么容错呢?

更新 json 文件以增加已创建主题的复制因子:

$cat /tmp/increase-replication-factor.json …
Run Code Online (Sandbox Code Playgroud)

apache-kafka kafka-consumer-api kafka-producer-api

3
推荐指数
1
解决办法
1616
查看次数

如何从字符数组复制到字符指针?

我试图从字符数组复制到字符指针.我的代码:

char str[] = "Hello World";
char *result = (char *)malloc(strlen(str)+1);
int index=0;
while(index <= strlen(str))
{
  *result = str[index];
  result++;
  index++;
}
Run Code Online (Sandbox Code Playgroud)

上面的代码不起作用,下面的代码工作正常

char str[] = "Hello World";
char *result = (char *)malloc(strlen(str)+1);
int index=0;
while(index <= strlen(str))
{
  result[index] = str[index];
  index++;
}
Run Code Online (Sandbox Code Playgroud)

谁能解释这种行为?

c

2
推荐指数
2
解决办法
2万
查看次数

执行csh脚本时如何显示行号?

我正在使用 csh 脚本,我想在调试模式下执行 csh 脚本时查看行号。我正在做这样的事

csh -x 脚本名称

除此之外,我还需要做什么才能在调试模式下查看行号?

linux shell csh

1
推荐指数
1
解决办法
2872
查看次数

Can static variables be initialized multiple times?

I have read that static variables in c/c++ only initialised once.

But when i tried to experiment with it. I found that they can be initialised multiple times

#include <iostream> 
#include <string> 
using namespace std; 

void demo(int value) 
{ 
    // static variable 
    static int count = 0; 
    count = value; 
    cout << count << " "; 



} 

int main() 
{ 
    for (int i=0; i<5; i++)  
        demo(i+1); 
    return 0; 
} 
Run Code Online (Sandbox Code Playgroud)

In above code my initialised static variable count multiple times.

output …

c++

1
推荐指数
1
解决办法
101
查看次数