小编dig*_*ise的帖子

安排 AWS ECS Fargate 启动和停止任务

根据 AWS 文档,他们说:“ Fargate 支持调度任务以响应 CloudWatch Events。您可以轻松启动和停止只需要在特定时间运行的 Fargate 任务

可以从CloudWatch Events 或 ECS Task Scheduler轻松启用 Fargate 任务的启动。

但是我找不到 Fargate 任务的 STOP。是否可能需要使用 Lambda 而不是本机 Fargate 功能来停止任务?

我的目标是只在晚上 8 点到下午 5 点之间运行 ECS 容器!

amazon-web-services aws-fargate

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

Kafka Consumer将过多的DEBUG语句输出到控制台(Ecilpse)

我正在从http://www.javaworld.com/article/3060078/big-data/big-data-messaging-with-kafka-part-1.html?page=2运行一些示例代码,并且kafkaconsumer是根据需要使用主题,但每次轮询都会打印(以输出)许多调试日志,这是我不想要的。

我尝试将所有的INFO和DEBUG更改为ERROR(甚至做了grep来确保)/config/log4j.properties,特别是设置log4j.logger.kafka=ERRORkafkaAppender,但是问题仍然存在。我提到了如何为Kafka生产者配置日志记录?,并在那里采用了解决方案,但是对于消费者来说情况可能有所不同吗?

DEBUG消息均具有类似的格式:

[Thread-0] DEBUG org.apache.kafka.clients.consumer.internals.Fetcher - Sending fetch for partitions... to broker... (id: 0 rack: null)
Run Code Online (Sandbox Code Playgroud)

并以每秒10左右的速度出现(我尝试将poll参数更改为1000甚至10000并没有帮助)

非常感谢任何专家的帮助。提前致谢!

编辑:不确定是否重要,但是我将其添加BasicConfigurator.configure();到了我的主要方法中,以解决以前发生的其他一些错误,这些错误甚至阻止了使用者启动。

java logging log4j apache-kafka kafka-consumer-api

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

Websocket - IOException:打开的文件太多

我正在使用Spring boot的WebSocketConfigurer来创建websocket,按照以下代码创建一个在线系统.我的用户将连接到它,它将继续跟踪他们的存在.

@Configuration
@EnableWebSocket
public class WebSocketServerConfiguration implements WebSocketConfigurer {

private final PresenceListener presenceListener;
Logger logger = Logger.getLogger(WebSocketServerConfiguration.class.getName());

@Autowired
public WebSocketServerConfiguration(StringRedisTemplate stringRedisTemplate){
    this.presenceListener = new PresenceListener(stringRedisTemplate);
}

@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
    registry.addHandler(new WebSocketHandler() {
        @Override
        public void afterConnectionEstablished(WebSocketSession session) throws Exception {
            logger.info("afterConnectionEstablished:"+session.toString());
        }

        @Override
        public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
            //Some code inside
        }

        @Override
        public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
            logger.info("handleTransportError:" +session.toString());
        }

        @Override
        public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) …
Run Code Online (Sandbox Code Playgroud)

java spring-boot spring-websocket

5
推荐指数
0
解决办法
472
查看次数

MVC:为什么控制器是视图的策略

这是定义Strategy Pattern:

策略 - 定义一系列算法,封装每个算法,并使它们可互换.策略允许算法独立于使用它的客户端.

因此,策略将功能分为两部分:一部分不改变,另一部分可以在未来某个时间改变.

而且,在MVC中,他们说:

控制器是视图的策略

这意味着控制器是变化的,View将来可能不会改变.

我还不太了解.我想他们两个都可以在未来改变.

请解释一下为什么人们这么说.

model-view-controller design-patterns strategy-pattern design-principles

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

OpenJDK 11 错误“无法初始化加密机制”

我有一个用 openJDK (Amazon Correto 11) 和 openJFX 编写的应用程序。

当我在本地运行应用程序时 - 一切正常。但是当我从网络共享执行应用程序时出现异常:

java.lang.ExceptionInInitializerError
    at java.base/javax.crypto.JceSecurityManager.<clinit>(JceSecurityManager.java:65)
    at java.base/javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2624)
    at java.base/javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2646)
    at java.base/sun.security.ssl.SSLCipher.isUnlimited(SSLCipher.java:540)
    at java.base/sun.security.ssl.SSLCipher.<init>(SSLCipher.java:472)
    at java.base/sun.security.ssl.SSLCipher.<clinit>(SSLCipher.java:174)
    at java.base/sun.security.ssl.CipherSuite.<clinit>(CipherSuite.java:67)
    at java.base/sun.security.ssl.SSLContextImpl.getApplicableSupportedCipherSuites(SSLContextImpl.java:348)
    at java.base/sun.security.ssl.SSLContextImpl$AbstractTLSContext.<clinit>(SSLContextImpl.java:579)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at java.base/java.security.Provider$Service.getImplClass(Provider.java:1848)
    at java.base/java.security.Provider$Service.newInstance(Provider.java:1824)
    at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
    at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
    at java.base/javax.net.ssl.SSLContext.getInstance(SSLContext.java:168)
    at org.apache.http.ssl.SSLContexts.createDefault(SSLContexts.java:51)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.getSocketFactory(SSLConnectionSocketFactory.java:194)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.getDefaultRegistry(PoolingHttpClientConnectionManager.java:115)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:122)
    at com.mashape.unirest.http.options.Options.refresh(Options.java:72)
    at com.mashape.unirest.http.options.Options.<clinit>(Options.java:46)
    at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151)
    at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
    at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)
    at myapp.util.MyTaxNumberValidator$3.run(MyTaxNumberValidator.java:185)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
    at java.base/javax.crypto.JceSecurity.<clinit>(JceSecurity.java:120)
    ... 27 more …
Run Code Online (Sandbox Code Playgroud)

java jce amazon-web-services openjdk-11

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

为什么Kotlin不能覆盖List <*>运算符方法?

这是我的功能:

operator  infix fun  List<Teacher>.get(int: Int): Teacher {
    var t = Teacher()
    t.name = "asd"
    return t ;
}
Run Code Online (Sandbox Code Playgroud)

和我的用法:

b[0].teachers[1].name
Run Code Online (Sandbox Code Playgroud)

提示:b是具有List <Teacher>属性的对象

和错误Empty list doesn't contain element at index 1.

为什么这个覆盖操作员功能不起作用?

kotlin

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

追加到 utf8 格式的文件

对于一个项目,我需要使用 UTF-8 编码附加到文本文件。在我的研究过程中,我发现了两种可能性:

BufferedWriter out = new BufferedWriter(
    new OutputStreamWriter(new FileOutputStream("file.txt), "UTF-8")
)
Run Code Online (Sandbox Code Playgroud)

这将以 UTF-8 格式写入我的文件,但它会覆盖它,而不是附加到它(如果它已经存在)。

然后我找到了用 中的参数附加到现有文件的代码FileWriter,但这不会明确使用 UTF-8,而不是使用默认的系统字符集:

BufferedWriter out = new BufferedWriter(new FileWriter("myfile.txt", true))
Run Code Online (Sandbox Code Playgroud)

我现在需要能够定义编码以及附加到文件。仅依赖系统编码或更改这不是一个选择。

有什么想法吗?

java append character-encoding bufferedwriter

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