小编Kho*_*zzy的帖子

ScheduledThreadPoolExecutor,如何停止runnable类JAVA

我写了以下代码:

import java.util.Calendar;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

class Voter {   
public static void main(String[] args) {
    ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(2);
    stpe.scheduleAtFixedRate(new Shoot(), 0, 1, TimeUnit.SECONDS);
}
}

class Shoot implements Runnable {
Calendar deadline;
long endTime,currentTime;

public Shoot() {
    deadline = Calendar.getInstance();
    deadline.set(2011,6,21,12,18,00);
    endTime = deadline.getTime().getTime();
}

public void work() {
    currentTime = System.currentTimeMillis();

    if (currentTime >= endTime) {
        System.out.println("Got it!");
        func();
    } 
}

public void run() {
    work();
}

public void func() {
    // function called when time …
Run Code Online (Sandbox Code Playgroud)

java runnable

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

端点SWS没有适配器

我正在尝试使用教程创建一个简单的Hello World WebService .

我正在运行Java 1.7.0_04,Spring 2.1,所有内容都是使用Maven构建的,并使用Tomcat6进行部署.但是,当尝试发送SOAP请求(soapUI)时,服务器返回我

No adapter for endpoint [public org.jdom.Element com.mycompany.hr.ws.HolidayEndpoint.handleHolidayRequest(org.jdom.Element) throws java.lang.Exception]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
Run Code Online (Sandbox Code Playgroud)

我认为注释有问题,但这是我的文件的样子:

web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">

    <display-name>Khozzy custom WebService</display-name>

    <servlet>
        <servlet-name>spring-ws</servlet-name>
        <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>

        <init-param>
            <param-name>transformWsdlLocations</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>spring-ws</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

</web-app>
Run Code Online (Sandbox Code Playgroud)

弹簧-WS-servlet.xml中

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:sws="http://www.springframework.org/schema/web-services"
       xsi:schemaLocation=" http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                            http://www.springframework.org/schema/web-services
                            http://www.springframework.org/schema/web-services/web-services-2.0.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="com.mycompany.hr.ws" …
Run Code Online (Sandbox Code Playgroud)

spring soap annotations adapter endpoint

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

Web UI如何计算存储内存(在Executors选项卡中)?

我试图了解Spark 2.1.0如何在节点上分配内存.

假设我正在启动一个本地PySpark REPL,为它分配2GB的内存:

$ pyspark --conf spark.driver.memory=2g
Run Code Online (Sandbox Code Playgroud)

Spark UI告诉我们为存储内存分配了956.6 MB:

在此输入图像描述

我不明白如何达到这个数字,这是我的思考过程:

  1. 驱动程序堆大小设置为2048 MB,
  2. 根据文档:(2048 MB - 300 MB) * 0.6 = 1048.8 MB用于执行和存储区域(统一),
  3. 另外,1048.8 MB * 0.5 = 524.4 MB在统一区域内应保留为免疫存储区域

那么,Spark中956.6 MB的值是如何实际计算的呢?

apache-spark pyspark

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

从Artifactory下载工件存档

我正在测试Artifactory 4.2.0 PRO.

非常好的功能是可以通过执行下载构建生成的所有文件的存档,例如:

curl -XPOST -u admin:password -H "Content-Type: application/json"  http://localhost:8081/artifactory/api/archive/buildArtifacts -d '
{
      "buildName": "Vehicle Routing Problem", 
      "buildNumber": "3", 
      "archiveType": "zip"
}' > build.zip
Run Code Online (Sandbox Code Playgroud)

但是,在使用AQL指定确切属性时,我无法找到是否有可能执行相同操作(下载存档).我一直在尝试上传其他工件,其属性与构建推送的属性完全相同,但它们不是由上面的代码段获取(我假设某种元数据存储在某处).

在不使用许多HTTP查询的情况下获取多个工件的可能性有多大?

问候.

repository artifactory

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

使用 HTTP BASIC AUTH 保护 Docker 容器

考虑运行一个带有暴露特定端口的 Web 应用程序的 Docker 容器。如何在访问 URL (HTTP BASIC AUTH) 之前应用额外的安全层?

Docker 引擎版本 >= 1.9.1

security authentication nginx docker

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

在Artifactory用户插件中获取文件内容

是否可以在用户插件中的beforeCreate事件期间(在将文件保存到存储库之前)获取文件内容?

我正在运行Artifactory 4.3.1.

代码段:

import org.artifactory.fs.FileInfo

storage {
  beforeCreate { item ->
    item = item as FileInfo

    log.warn "Analyzing item: ${item}"
    // I want to do something with the file/item contents here (for example extract ZIP)
  } 
}
Run Code Online (Sandbox Code Playgroud)

感谢帮助!

plugins repository artifactory

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