小编Nil*_*pal的帖子

Java中的AtomicLong用于什么?

有人可以解释一下AtomicLong的用途吗?例如,以下陈述的区别是什么?

private Long transactionId;
private AtomicLong transactionId;
Run Code Online (Sandbox Code Playgroud)

java atomic-long

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

ERROR向主题发送消息时出错

在kafka中生成消息时,我收到以下错误:

$ bin/kafka-console-producer.sh --broker-list localhost:9092 --topic nil_PF1_P1
hi
hello

[2016-07-19 17:06:34,542] ERROR Error when sending message to topic nil_PF1_P1 with key: null, value: 2 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
[2016-07-19 17:07:34,544] ERROR Error when sending message to topic nil_PF1_P1 with key: null, value: 5 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.


$ bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic nil_PF1_P1
Topic:nil_PF1_P1    PartitionCount:1    ReplicationFactor:1 Configs:
Topic: nil_PF1_P1   Partition: 0    Leader: 2 …
Run Code Online (Sandbox Code Playgroud)

apache-kafka

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

使用命令行在kafka中使用消息时如何设置组名

知道如何在使用命令行在kafka中使用消息时设置组名.

我尝试使用以下命令:

bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic nil_RF2_P2 --from-beginning --config group.id=test1
'config' is not a recognized option
Run Code Online (Sandbox Code Playgroud)

目标是使用以下命令查找消耗的消息的偏移量:

bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper localhost:2181 --group test1
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙!

提前致谢 !!

apache-kafka kafka-consumer-api

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

错误:在 ADO 管道中运行 Azure CLI 任务时无法找到可执行文件:“powershell”

我尝试在管道中运行 Azure CLI 任务并收到以下错误:

Starting: AzureCLI
==============================================================================
Task         : Azure CLI
Description  : Run Azure CLI commands against an Azure subscription in a PowerShell 
Core/Shell script when running on Linux agent or PowerShell/PowerShell Core/Batch script when running on Windows agent.
Version      : 2.1.0
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
==============================================================================
##[error]Script failed with error: Error: Unable to locate executable file: 'powershell'. Please verify either the file path exists or the file can be found within a directory specified by …
Run Code Online (Sandbox Code Playgroud)

azure-cli azure-devops azure-pipelines azure-pipelines-yaml

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

错误:请求的资源需要用户身份验证:在 AzureCLI 任务构建管道中

我无法从 azureCLI 任务触发 azure 管道构建

任务 :

- task: AzureCLI@2
  inputs:
    azureSubscription: 'Free Trial(My subscription)'
    scriptType: 'pscore'
    scriptLocation: 'inlineScript'
    inlineScript: |
      az --version
      echo "Running : az account show"
      az account show
      #export AZURE_DEVOPS_EXT_PAT='mypat'
      $env:AZURE_DEVOPS_EXT_PAT='mypat'
      az pipelines create --name newPipeline --org https://dev.azure.com/AbiNilOrg/ --project azure-devops-kubernetes-terraform --branch master
Run Code Online (Sandbox Code Playgroud)

输出有错误:

Running : az account show
{
  "environmentName": "AzureCloud",
  "homeTenantId": "***",
  "id": "73c1af29-384c-4574-bd88-92d7bb392cfc",
  "isDefault": true,
  "managedByTenants": [],
  "name": "Free Trial",
  "state": "Enabled",
  "tenantId": "***",
  "user": {
    "name": "***",
    "type": "servicePrincipal"
  }
}
WARNING: This …
Run Code Online (Sandbox Code Playgroud)

azure azure-cli azure-devops azure-pipelines azure-pipelines-yaml

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

在Java 8中,当流中的重复键时,如何收集形成List的值

我有一个二维数组或元素形式的元素流EntrySet.我需要将它们收集起来Map.现在的问题是元素流可以有重复的元素.假设我希望该值为列表:

Map<String,List<String>>
Run Code Online (Sandbox Code Playgroud)

示例:

class MapUtils
{
// Function to get Stream of String[]
private static Stream<String[]> getMapStream()
{
    return Stream.of(new String[][] {
            {"CAR", "Audi"},
            {"BIKE", "Harley Davidson"},
            {"BIKE", "Pulsar"}
    });
}

// Program to convert Stream to Map in Java 8
public static void main(String args[])
{
    // get stream of String[]
    Stream<String[]> stream = getMapStream();

    // construct a new map from the stream
    Map<String, String> vehicle =
            stream.collect(Collectors.toMap(e -> e[0], e -> e[1]));

    System.out.println(vehicle);
} …
Run Code Online (Sandbox Code Playgroud)

java hashmap java-8 java-stream

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

为什么docker ps -a的名称列总是不同的

刚和码头玩家一起玩!!

跑ps命令-a选项

docker run -a
C:\Users\sarkan1>docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
3d6db385321c        busybox:1.24        "sleep 1000"        26 seconds ago      Up 24 seconds                                   lucid_ramanujan
e6acd65398b2        hello-world         "/hello"            43 minutes ago      Exited (0) 43 minutes ago                       nifty_brattain
c5576137580d        hello-world         "/hello"            4 days ago          Exited (0) 4 days ago                           dreamy_aryabhata
2594fbf1fa82        hello-world         "/hello"            4 days ago          Exited (0) 4 days ago                           nostalgic_hopper
c0102bc64c45        hello-world         "/hello"            4 days ago          Exited (0) 4 days ago                           vibrant_khorana
Run Code Online (Sandbox Code Playgroud)

c4af79ea96e9 hello-world"/ hello"4天前退出(0)4天前cranky_heyrovsky

问题:

  1. 为什么我在名称列中的值总是不同?我想我跑了同样的容器!! …

docker docker-image

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

Jacoco 无法覆盖仅包含静态方法的类

Jacoco 无法覆盖仅包含静态方法的类。我没有在测试类中实例化该类,而是直接调用静态方法来测试。

public class DateUtil {
final static String datePattern = "EEE MM/dd/yyyy";

public static String convertToGMTDate(Date date ) {
    DateFormat df = new SimpleDateFormat(datePattern, Locale.getDefault());
    df.setTimeZone(TimeZone.getTimeZone("GMT"));
    return df.format(date);
  }
}



class DateUtilTest {
static DateUtil dateutil;
@Test
void convertToGMTDate() {
    Date date = new GregorianCalendar(2020, Calendar.FEBRUARY, 11).getTime();
    String stringDate = dateutil.convertToGMTDate(date);
    assertEquals("Tue 02/11/2020)",stringDate);
}
   
}
Run Code Online (Sandbox Code Playgroud)

错误报告仅突出显示了类名“DateUtil”,并报告其已覆盖 7​​5%。怎样做才能让课堂覆盖率达到100%?

不在测试方法中实例化该类,此处的覆盖率降低了 25%。这有什么意义呢?JaCoCo有缺陷吗?

提前致谢!

java jacoco jacoco-maven-plugin

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

kafka 0.8与kafka 0.10的差异

任何人都可以列出Kafka 0.10与kafka 0.8相比的基本差异化特征.

我们正在考虑将我们的kafka-8升级到kafka-10.升级中可能面临哪些挑战?

提前致谢.

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

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

-Dfile.encoding = UTF-8 在 JAVA_OPTIONS 中做什么

知道-Dfile.encoding=UTF-8是什么吗

JAVA_OPTIONS="${JAVA_OPTIONS} -Dfile.encoding=UTF-8"
Run Code Online (Sandbox Code Playgroud)

做?我的码头服务器配置中有这个选项。

如果我没有它,可能会产生什么后果?

java file utf-8 file-encodings jetty-9

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