{"action":"created","comment":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/37778295","id":37778295,"diff_hunk":"@@ -0,0 +1,251 @@\n+/* This file is part of VoltDB.\n+ * Copyright (C) 2008-2015 VoltDB Inc.\n+ *\n+ * This program is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU Affero General Public License as\n+ * published by the Free Software Foundation, either version 3 of the\n+ * License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU Affero General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Affero General Public License\n+ * along with VoltDB.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+package org.voltdb;\n+\n+import java.io.File;\n+import java.util.EnumSet;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+\n+import org.voltcore.logging.Level;\n+import org.voltcore.logging.VoltLogger;\n+import org.voltdb.compiler.deploymentfile.DiskLimitType;\n+import org.voltdb.compiler.deploymentfile.FeatureNameType;\n+import org.voltdb.compiler.deploymentfile.PathsType;\n+import org.voltdb.compiler.deploymentfile.SystemSettingsType;\n+import org.voltdb.licensetool.LicenseApi;\n+import org.voltdb.utils.CatalogUtil;\n+import org.voltdb.utils.MiscUtils;\n+\n+/**\n+ * Disk space monitoring related functionality of resource monitoring.\n+ */\n+public class DiskResourceChecker\n+{\n+    private static final VoltLogger m_logger = new VoltLogger(\"HOST\");\n+\n+    static FileCheckForTest s_testFileCheck; // used only for testing\n+    private final Map<FeatureNameType, FeatureDiskLimitConfig> m_configuredLimits = new HashMap<>();\n+\n+    public DiskResourceChecker(SystemSettingsType systemSettings, PathsType pathsConfig)\n+    {\n+        findDiskLimitConfiguration(systemSettings, pathsConfig);\n+    }\n+\n+    public boolean hasLimitsConfigured()\n+    {\n+        for (FeatureDiskLimitConfig config : m_configuredLimits.values())\n+        {\n+            if (config.m_diskSizeLimit > 0 || config.m_diskSizeLimitPerc > 0) {\n+                return true;\n+            }\n+        }\n+\n+        return false;\n+    }\n+\n+    public void logConfiguredLimits()\n+    {\n+        for (FeatureDiskLimitConfig config : m_configuredLimits.values())\n+        {\n+            if (config.m_diskSizeLimit > 0 || config.m_diskSizeLimitPerc > 0) {\n+                m_logger.info(config.m_featureName.value() + \" on \" + config.m_path + \" configured with size limit: \" +\n+                        (config.m_diskSizeLimit > 0 ? config.m_diskSizeLimit + \"GB\" : config.m_diskSizeLimitPerc + \"%\"));\n+            }\n+        }\n+    }\n+\n+    public boolean isOverLimitConfiguration()\n+    {\n+        for (FeatureDiskLimitConfig config : m_configuredLimits.values())\n+        {\n+            if (config.m_diskSizeLimit <= 0 && config.m_diskSizeLimitPerc <= 0) {\n+                continue;\n+            }\n+            if (!isDiskAvailable(config.m_path, config.m_diskSizeLimitPerc, config.m_diskSizeLimit)) {\n+                m_logger.warn(\"Disk is over configred limits for feature \" + config.m_featureName);\n+                return true;\n+            }\n+        }\n+\n+        return false;\n+    }\n+\n+    private void findDiskLimitConfiguration(SystemSettingsType systemSettings, PathsType pathsConfig)\n+    {\n+        // By now we know that resource monitor is not null\n+        DiskLimitType diskLimitConfig = systemSettings.getResourcemonitor().getDisklimit();\n+        if (diskLimitConfig==null) {\n+            return;\n+        }\n+\n+        String defaultSize = diskLimitConfig.getSize();\n+        List<DiskLimitType.Feature> features = diskLimitConfig.getFeature();\n+        //If defaultsize is configured, that should be set as the limit size for all features not explicitly configured\n+        if ( (features==null || features.isEmpty()) && (defaultSize == null || defaultSize.trim().isEmpty()) ) {\n+            return;\n+        }\n+\n+        EnumSet<FeatureNameType> configuredFeatures = EnumSet.noneOf(FeatureNameType.class);\n+        if (features!=null && !features.isEmpty())\n+        {\n+            for (DiskLimitType.Feature feature : features) {\n+                configuredFeatures.add(feature.getName());\n+                if (!isSupportedFeature(feature.getName())) {\n+                    m_logger.warn(\"Ignoring unsupported feature \" + feature.getName());\n+                    continue;\n+                }\n+                String size = feature.getSize();\n+                m_configuredLimits.put(feature.getName(),\n+                        new FeatureDiskLimitConfig(feature.getName(), pathsConfig, size));\n+                if (m_logger.isDebugEnabled()) {\n+                    m_logger.debug(\"Added disk usage limit configuration \" + size + \" for feature \" + feature.getName());\n+                }\n+            }\n+        }\n+\n+        if (defaultSize !=null && !defaultSize.trim().isEmpty())\n+        {\n+            EnumSet<FeatureNameType> forDefault = EnumSet.complementOf(configuredFeatures);\n+            for (FeatureNameType featureName : forDefault)\n+            {\n+                if (!isSupportedFeature(featureName)) {\n+                    continue;\n+                }\n+                m_configuredLimits.put(featureName,\n+                        new FeatureDiskLimitConfig(featureName, pathsConfig, defaultSize));\n+                if (m_logger.isDebugEnabled()) {\n+                    m_logger.debug(\"Added disk usage limit configuration \" + defaultSize + \" for feature \" + featureName);\n+                }\n+            }\n+        }\n+    }\n+\n+    private boolean isSupportedFeature(FeatureNameType featureName)\n+    {\n+        LicenseApi licenseApi = VoltDB.instance().getLicenseApi();\n+        switch(featureName)\n+        {\n+        case COMMANDLOG:\n+        case COMMANDLOGSNAPSHOT:\n+            return licenseApi.isCommandLoggingAllowed();\n+        case DROVERFLOW:\n+            return licenseApi.isDrReplicationAllowed();\n+        case EXPORTOVERFLOW:\n+            return MiscUtils.isPro();\n+        case SNAPSHOTS:","path":"src/frontend/org/voltdb/DiskResourceChecker.java","position":152,"original_position":152,"commit_id":"8c4365f319577e9baed4ae9eaf3f857bf4dc6cf9","original_commit_id":"8c4365f319577e9baed4ae9eaf3f857bf4dc6cf9","user":{"login":"manjujames","id":12613581,"avatar_url":"https://avatars.githubusercontent.com/u/12613581?v=3","gravatar_id":"","url":"https://api.github.com/users/manjujames","html_url":"https://github.com/manjujames","followers_url":"https://api.github.com/users/manjujames/followers","following_url":"https://api.github.com/users/manjujames/following{/other_user}","gists_url":"https://api.github.com/users/manjujames/gists{/gist_id}","starred_url":"https://api.github.com/users/manjujames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manjujames/subscriptions","organizations_url":"https://api.github.com/users/manjujames/orgs","repos_url":"https://api.github.com/users/manjujames/repos","events_url":"https://api.github.com/users/manjujames/events{/privacy}","received_events_url":"https://api.github.com/users/manjujames/received_events","type":"User","site_admin":false},"body":"Oh yes, thanks.","created_at":"2015-08-24T17:39:15Z","updated_at":"2015-08-24T17:39:15Z","html_url":"https://github.com/VoltDB/voltdb/pull/2720#discussion_r37778295","pull_request_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2720","_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/37778295"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/2720#discussion_r37778295"},"pull_request":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2720"}}},"pull_request":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2720","id":42850871,"html_url":"https://github.com/VoltDB/voltdb/pull/2720","diff_url":"https://github.com/VoltDB/voltdb/pull/2720.diff","patch_url":"https://github.com/VoltDB/voltdb/pull/2720.patch","issue_url":"https://api.github.com/repos/VoltDB/voltdb/issues/2720","number":2720,"state":"open","locked":false,"title":"Eng 8772 - Disk space monitoring and pausing the server","user":{"login":"manjujames","id":12613581,"avatar_url":"https://avatars.githubusercontent.com/u/12613581?v=3","gravatar_id":"","url":"https://api.github.com/users/manjujames","html_url":"https://github.com/manjujames","followers_url":"https://api.github.com/users/manjujames/followers","following_url":"https://api.github.com/users/manjujames/following{/other_user}","gists_url":"https://api.github.com/users/manjujames/gists{/gist_id}","starred_url":"https://api.github.com/users/manjujames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manjujames/subscriptions","organizations_url":"https://api.github.com/users/manjujames/orgs","repos_url":"https://api.github.com/users/manjujames/repos","events_url":"https://api.github.com/users/manjujames/events{/privacy}","received_events_url":"https://api.github.com/users/manjujames/received_events","type":"User","site_admin":false},"body":"Junit is in pro because the features are enabled in Pro only.","created_at":"2015-08-19T18:57:45Z","updated_at":"2015-08-24T17:39:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"35947b1c479856fba3b23cff5b2c08bf7c175e01","assignee":{"login":"akhanzode","id":1675698,"avatar_url":"https://avatars.githubusercontent.com/u/1675698?v=3","gravatar_id":"","url":"https://api.github.com/users/akhanzode","html_url":"https://github.com/akhanzode","followers_url":"https://api.github.com/users/akhanzode/followers","following_url":"https://api.github.com/users/akhanzode/following{/other_user}","gists_url":"https://api.github.com/users/akhanzode/gists{/gist_id}","starred_url":"https://api.github.com/users/akhanzode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akhanzode/subscriptions","organizations_url":"https://api.github.com/users/akhanzode/orgs","repos_url":"https://api.github.com/users/akhanzode/repos","events_url":"https://api.github.com/users/akhanzode/events{/privacy}","received_events_url":"https://api.github.com/users/akhanzode/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2720/commits","review_comments_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2720/comments","review_comment_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/issues/2720/comments","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/8c4365f319577e9baed4ae9eaf3f857bf4dc6cf9","head":{"label":"VoltDB:ENG-8772","ref":"ENG-8772","sha":"8c4365f319577e9baed4ae9eaf3f857bf4dc6cf9","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","created_at":"2011-09-23T18:46:12Z","updated_at":"2015-08-17T11:00:07Z","pushed_at":"2015-08-24T16:42:16Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":887626,"stargazers_count":615,"watchers_count":615,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":180,"mirror_url":null,"open_issues_count":40,"forks":180,"open_issues":40,"watchers":615,"default_branch":"master"}},"base":{"label":"VoltDB:master","ref":"master","sha":"24edb4475fe1ec0b9b100df45913ec40e0ab90f0","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","created_at":"2011-09-23T18:46:12Z","updated_at":"2015-08-17T11:00:07Z","pushed_at":"2015-08-24T16:42:16Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":887626,"stargazers_count":615,"watchers_count":615,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":180,"mirror_url":null,"open_issues_count":40,"forks":180,"open_issues":40,"watchers":615,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2720"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/2720"},"issue":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/2720"},"comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/2720/comments"},"review_comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2720/comments"},"review_comment":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2720/commits"},"statuses":{"href":"https://api.github.com/repos/VoltDB/voltdb/statuses/8c4365f319577e9baed4ae9eaf3f857bf4dc6cf9"}}}}