{"action":"created","issue":{"url":"https://api.github.com/repos/apache/brooklyn-server/issues/449","repository_url":"https://api.github.com/repos/apache/brooklyn-server","labels_url":"https://api.github.com/repos/apache/brooklyn-server/issues/449/labels{/name}","comments_url":"https://api.github.com/repos/apache/brooklyn-server/issues/449/comments","events_url":"https://api.github.com/repos/apache/brooklyn-server/issues/449/events","html_url":"https://github.com/apache/brooklyn-server/pull/449","id":190636139,"number":449,"title":"Increase persistence timeout","user":{"login":"neykov","id":3612111,"avatar_url":"https://avatars.githubusercontent.com/u/3612111?v=3","gravatar_id":"","url":"https://api.github.com/users/neykov","html_url":"https://github.com/neykov","followers_url":"https://api.github.com/users/neykov/followers","following_url":"https://api.github.com/users/neykov/following{/other_user}","gists_url":"https://api.github.com/users/neykov/gists{/gist_id}","starred_url":"https://api.github.com/users/neykov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neykov/subscriptions","organizations_url":"https://api.github.com/users/neykov/orgs","repos_url":"https://api.github.com/users/neykov/repos","events_url":"https://api.github.com/users/neykov/events{/privacy}","received_events_url":"https://api.github.com/users/neykov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-21T07:11:18Z","updated_at":"2016-11-22T17:24:49Z","closed_at":"2016-11-22T13:07:47Z","pull_request":{"url":"https://api.github.com/repos/apache/brooklyn-server/pulls/449","html_url":"https://github.com/apache/brooklyn-server/pull/449","diff_url":"https://github.com/apache/brooklyn-server/pull/449.diff","patch_url":"https://github.com/apache/brooklyn-server/pull/449.patch"},"body":"File access locks for exactly 30 seconds in Virtualbox."},"comment":{"url":"https://api.github.com/repos/apache/brooklyn-server/issues/comments/262306287","html_url":"https://github.com/apache/brooklyn-server/pull/449#issuecomment-262306287","issue_url":"https://api.github.com/repos/apache/brooklyn-server/issues/449","id":262306287,"user":{"login":"neykov","id":3612111,"avatar_url":"https://avatars.githubusercontent.com/u/3612111?v=3","gravatar_id":"","url":"https://api.github.com/users/neykov","html_url":"https://github.com/neykov","followers_url":"https://api.github.com/users/neykov/followers","following_url":"https://api.github.com/users/neykov/following{/other_user}","gists_url":"https://api.github.com/users/neykov/gists{/gist_id}","starred_url":"https://api.github.com/users/neykov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neykov/subscriptions","organizations_url":"https://api.github.com/users/neykov/orgs","repos_url":"https://api.github.com/users/neykov/repos","events_url":"https://api.github.com/users/neykov/events{/privacy}","received_events_url":"https://api.github.com/users/neykov/received_events","type":"User","site_admin":false},"created_at":"2016-11-22T17:24:48Z","updated_at":"2016-11-22T17:24:48Z","body":"For the record I'm adding the test case here. It's the plain java equivalent of the merged test.\r\n```\r\n\r\nimport java.io.File;\r\nimport java.io.FileWriter;\r\nimport java.io.IOException;\r\nimport java.io.Writer;\r\nimport java.util.ArrayList;\r\nimport java.util.Collection;\r\nimport java.util.concurrent.Callable;\r\nimport java.util.concurrent.ExecutorService;\r\nimport java.util.concurrent.Executors;\r\nimport java.util.concurrent.Future;\r\n\r\npublic class FileWriteSimpleTest {\r\n    private static final int THREAD_COUNT = 2;\r\n    private static final long FILE_OPERATION_TIMEOUT_MS = 20000;\r\n    private static final String TEST_FILE_CONTENT = generateContent();\r\n    private static final ExecutorService executor = Executors.newFixedThreadPool(THREAD_COUNT);\r\n\r\n    private static class FileWriterTask implements Callable<FileWriterTask> {\r\n        @Override\r\n        public FileWriterTask call() throws Exception {\r\n            try {\r\n                File tmp = File.createTempFile(getClass().getName() + \".\", \".txt\");\r\n                try(Writer out = new FileWriter(tmp)) {\r\n                    out.write(TEST_FILE_CONTENT);\r\n                }\r\n                File dst = new File(tmp.getParentFile(), tmp.getName() + \".renamed\");\r\n                if (!tmp.renameTo(dst)) {\r\n                    throw new IOException(\"Couldn't rename file \" + tmp + \" to \" + dst);\r\n                }\r\n                if (!dst.delete()) {\r\n                    throw new IOException(\"Couldn't delete file \" + tmp);\r\n                }\r\n                return this;\r\n            } catch (IOException e) {\r\n                throw new IllegalStateException(e);\r\n            }\r\n        }\r\n    };\r\n    \r\n    public void testSimpleOperationsDelay() throws Exception {\r\n        Collection<Future<FileWriterTask>> tasks = new ArrayList<>(THREAD_COUNT);\r\n        for (int i = 0; i < THREAD_COUNT; i++) {\r\n            tasks.add(executor.submit(new FileWriterTask()));\r\n        }\r\n        long timeStart = System.currentTimeMillis();\r\n        for (Future<FileWriterTask> task : tasks) {\r\n            task.get();\r\n        }\r\n        long timeEnd = System.currentTimeMillis();\r\n        long timeSpent = timeEnd - timeStart;\r\n        if (timeSpent > FILE_OPERATION_TIMEOUT_MS) {\r\n            throw new IllegalStateException(\"Timed out waiting for tasks - \" + timeSpent);\r\n        }\r\n    }\r\n    \r\n    public void testSimpleOperationsDelayManyTimes() throws Exception {\r\n        try {\r\n            for (int i = 1; i <= 5000; i++) {\r\n                if (i % 100 == 0) {\r\n                    System.out.println(\"Iteration \" + i);\r\n                }\r\n                testSimpleOperationsDelay();\r\n            }\r\n        } finally {\r\n            executor.shutdown();\r\n        }\r\n    }\r\n\r\n    private static String generateContent() {\r\n        final char[] charArray = new char[4096];\r\n        java.util.Arrays.fill(charArray, ' ');\r\n        return new String(charArray);\r\n    }\r\n\r\n    public static void main(String[] args) throws Exception {\r\n        new FileWriteSimpleTest().testSimpleOperationsDelayManyTimes();\r\n    }\r\n\r\n}\r\n```"}}
{"actor":{"display_login":"neykov"}}