{"action":"created","comment":{"url":"https://api.github.com/repos/ehcache/ehcache3/pulls/comments/68652666","id":68652666,"diff_hunk":"@@ -0,0 +1,171 @@\n+/*\n+ * Copyright Terracotta, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.ehcache.clustered.client;\n+\n+import org.ehcache.Cache;\n+import org.ehcache.CachePersistenceException;\n+import org.ehcache.PersistentCacheManager;\n+import org.ehcache.StateTransitionException;\n+import org.ehcache.Status;\n+import org.ehcache.clustered.client.config.builders.ClusteredResourcePoolBuilder;\n+import org.ehcache.clustered.client.internal.UnitTestConnectionService;\n+import org.ehcache.config.builders.CacheConfigurationBuilder;\n+import org.ehcache.config.builders.CacheManagerBuilder;\n+import org.ehcache.config.builders.ResourcePoolsBuilder;\n+import org.ehcache.config.units.MemoryUnit;\n+import org.junit.After;\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+import java.net.URI;\n+\n+import static org.ehcache.clustered.client.config.builders.ClusteringServiceConfigurationBuilder.cluster;\n+import static org.ehcache.config.builders.CacheManagerBuilder.newCacheManagerBuilder;\n+import static org.hamcrest.Matchers.is;\n+import static org.junit.Assert.assertThat;\n+\n+public class CacheManagerDestroyTest {\n+\n+  private static final URI CLUSTER_URI = URI.create(\"terracotta://example.com:9540/my-application\");\n+\n+  private static final CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder =\n+      newCacheManagerBuilder()\n+          .with(cluster(CLUSTER_URI).autoCreate());\n+\n+  @Before\n+  public void definePassthroughServer() throws Exception {\n+    UnitTestConnectionService.add(CLUSTER_URI,\n+        new UnitTestConnectionService.PassthroughServerBuilder()\n+            .resource(\"primary-server-resource\", 64, MemoryUnit.MB)\n+            .resource(\"secondary-server-resource\", 64, MemoryUnit.MB)\n+            .build());\n+  }\n+\n+  @After\n+  public void removePassthroughServer() throws Exception {\n+    UnitTestConnectionService.remove(CLUSTER_URI);\n+  }\n+\n+  @Test\n+  public void testDestroyCacheManagerWithSingleClient() throws CachePersistenceException {\n+    PersistentCacheManager persistentCacheManager = clusteredCacheManagerBuilder.build(true);\n+\n+    persistentCacheManager.close();\n+    persistentCacheManager.destroy();\n+\n+    assertThat(persistentCacheManager.getStatus(), is(Status.UNINITIALIZED));\n+  }\n+\n+  @Test\n+  public void testDestroyCacheManagerWithMultipleClients() throws CachePersistenceException {\n+    PersistentCacheManager persistentCacheManager1 = clusteredCacheManagerBuilder.build(true);\n+    PersistentCacheManager persistentCacheManager2 = clusteredCacheManagerBuilder.build(true);\n+\n+    persistentCacheManager1.close();\n+\n+    try {\n+      persistentCacheManager1.destroy();\n+    } catch (StateTransitionException e) {\n+      assertThat(e.getMessage(), is(\"Couldn't acquire cluster-wide maintenance lease\"));\n+    }\n+\n+    assertThat(persistentCacheManager1.getStatus(), is(Status.UNINITIALIZED));\n+\n+    assertThat(persistentCacheManager2.getStatus(), is(Status.AVAILABLE));\n+\n+    Cache<Long, String> cache = persistentCacheManager2.createCache(\"test\", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,\n+        ResourcePoolsBuilder.newResourcePoolsBuilder()\n+            .with(ClusteredResourcePoolBuilder.fixed(\"primary-server-resource\", 32, MemoryUnit.MB))));\n+\n+    cache.put(1L, \"One\");\n+\n+    assertThat(cache.get(1L), is(\"One\"));\n+\n+  }\n+\n+  @Test\n+  public void testDestroyCacheManagerDoesNotAffectsExistingCacheWithExistingClientsConnected() throws CachePersistenceException {\n+\n+    CacheManagerBuilder<PersistentCacheManager> cacheManagerBuilder = clusteredCacheManagerBuilder\n+        .withCache(\"test\", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,\n+            ResourcePoolsBuilder.newResourcePoolsBuilder()\n+                .with(ClusteredResourcePoolBuilder.fixed(\"primary-server-resource\", 32, MemoryUnit.MB))));\n+\n+    PersistentCacheManager persistentCacheManager1 = cacheManagerBuilder.build(true);\n+    PersistentCacheManager persistentCacheManager2 = cacheManagerBuilder.build(true);\n+\n+    persistentCacheManager1.close();\n+    try {\n+      persistentCacheManager1.destroy();","path":"clustered/client/src/test/java/org/ehcache/clustered/client/CacheManagerDestroyTest.java","position":113,"original_position":113,"commit_id":"2da4030f58b4a06522e97093dc6295eb791e9971","original_commit_id":"2da4030f58b4a06522e97093dc6295eb791e9971","user":{"login":"albinsuresh","id":1647963,"avatar_url":"https://avatars.githubusercontent.com/u/1647963?v=3","gravatar_id":"","url":"https://api.github.com/users/albinsuresh","html_url":"https://github.com/albinsuresh","followers_url":"https://api.github.com/users/albinsuresh/followers","following_url":"https://api.github.com/users/albinsuresh/following{/other_user}","gists_url":"https://api.github.com/users/albinsuresh/gists{/gist_id}","starred_url":"https://api.github.com/users/albinsuresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albinsuresh/subscriptions","organizations_url":"https://api.github.com/users/albinsuresh/orgs","repos_url":"https://api.github.com/users/albinsuresh/repos","events_url":"https://api.github.com/users/albinsuresh/events{/privacy}","received_events_url":"https://api.github.com/users/albinsuresh/received_events","type":"User","site_admin":false},"body":"Same as above.","created_at":"2016-06-27T20:45:32Z","updated_at":"2016-06-27T20:45:32Z","html_url":"https://github.com/ehcache/ehcache3/pull/1233#discussion_r68652666","pull_request_url":"https://api.github.com/repos/ehcache/ehcache3/pulls/1233","_links":{"self":{"href":"https://api.github.com/repos/ehcache/ehcache3/pulls/comments/68652666"},"html":{"href":"https://github.com/ehcache/ehcache3/pull/1233#discussion_r68652666"},"pull_request":{"href":"https://api.github.com/repos/ehcache/ehcache3/pulls/1233"}}},"pull_request":{"url":"https://api.github.com/repos/ehcache/ehcache3/pulls/1233","id":75350526,"html_url":"https://github.com/ehcache/ehcache3/pull/1233","diff_url":"https://github.com/ehcache/ehcache3/pull/1233.diff","patch_url":"https://github.com/ehcache/ehcache3/pull/1233.patch","issue_url":"https://api.github.com/repos/ehcache/ehcache3/issues/1233","number":1233,"state":"open","locked":false,"title":"closes #1193 : Issue 1193","user":{"login":"AbfrmBlr","id":4498935,"avatar_url":"https://avatars.githubusercontent.com/u/4498935?v=3","gravatar_id":"","url":"https://api.github.com/users/AbfrmBlr","html_url":"https://github.com/AbfrmBlr","followers_url":"https://api.github.com/users/AbfrmBlr/followers","following_url":"https://api.github.com/users/AbfrmBlr/following{/other_user}","gists_url":"https://api.github.com/users/AbfrmBlr/gists{/gist_id}","starred_url":"https://api.github.com/users/AbfrmBlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AbfrmBlr/subscriptions","organizations_url":"https://api.github.com/users/AbfrmBlr/orgs","repos_url":"https://api.github.com/users/AbfrmBlr/repos","events_url":"https://api.github.com/users/AbfrmBlr/events{/privacy}","received_events_url":"https://api.github.com/users/AbfrmBlr/received_events","type":"User","site_admin":false},"body":"Added some tests to verify destroy behavior for cache and cachemanager for user facing apis","created_at":"2016-06-27T17:39:18Z","updated_at":"2016-06-27T20:45:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4cc94e502fdd08a18b442848cf3c4527ab46667d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ehcache/ehcache3/pulls/1233/commits","review_comments_url":"https://api.github.com/repos/ehcache/ehcache3/pulls/1233/comments","review_comment_url":"https://api.github.com/repos/ehcache/ehcache3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ehcache/ehcache3/issues/1233/comments","statuses_url":"https://api.github.com/repos/ehcache/ehcache3/statuses/2da4030f58b4a06522e97093dc6295eb791e9971","head":{"label":"AbfrmBlr:issue-1193","ref":"issue-1193","sha":"2da4030f58b4a06522e97093dc6295eb791e9971","user":{"login":"AbfrmBlr","id":4498935,"avatar_url":"https://avatars.githubusercontent.com/u/4498935?v=3","gravatar_id":"","url":"https://api.github.com/users/AbfrmBlr","html_url":"https://github.com/AbfrmBlr","followers_url":"https://api.github.com/users/AbfrmBlr/followers","following_url":"https://api.github.com/users/AbfrmBlr/following{/other_user}","gists_url":"https://api.github.com/users/AbfrmBlr/gists{/gist_id}","starred_url":"https://api.github.com/users/AbfrmBlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AbfrmBlr/subscriptions","organizations_url":"https://api.github.com/users/AbfrmBlr/orgs","repos_url":"https://api.github.com/users/AbfrmBlr/repos","events_url":"https://api.github.com/users/AbfrmBlr/events{/privacy}","received_events_url":"https://api.github.com/users/AbfrmBlr/received_events","type":"User","site_admin":false},"repo":{"id":28589092,"name":"ehcache3","full_name":"AbfrmBlr/ehcache3","owner":{"login":"AbfrmBlr","id":4498935,"avatar_url":"https://avatars.githubusercontent.com/u/4498935?v=3","gravatar_id":"","url":"https://api.github.com/users/AbfrmBlr","html_url":"https://github.com/AbfrmBlr","followers_url":"https://api.github.com/users/AbfrmBlr/followers","following_url":"https://api.github.com/users/AbfrmBlr/following{/other_user}","gists_url":"https://api.github.com/users/AbfrmBlr/gists{/gist_id}","starred_url":"https://api.github.com/users/AbfrmBlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AbfrmBlr/subscriptions","organizations_url":"https://api.github.com/users/AbfrmBlr/orgs","repos_url":"https://api.github.com/users/AbfrmBlr/repos","events_url":"https://api.github.com/users/AbfrmBlr/events{/privacy}","received_events_url":"https://api.github.com/users/AbfrmBlr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AbfrmBlr/ehcache3","description":"Ehcache 3.x line ","fork":true,"url":"https://api.github.com/repos/AbfrmBlr/ehcache3","forks_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/forks","keys_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/teams","hooks_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/hooks","issue_events_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/issues/events{/number}","events_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/events","assignees_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/assignees{/user}","branches_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/branches{/branch}","tags_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/tags","blobs_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/git/refs{/sha}","trees_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/statuses/{sha}","languages_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/languages","stargazers_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/stargazers","contributors_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/contributors","subscribers_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/subscribers","subscription_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/subscription","commits_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/commits{/sha}","git_commits_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/git/commits{/sha}","comments_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/comments{/number}","issue_comment_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/issues/comments{/number}","contents_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/contents/{+path}","compare_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/merges","archive_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/downloads","issues_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/issues{/number}","pulls_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/pulls{/number}","milestones_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/milestones{/number}","notifications_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/labels{/name}","releases_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/releases{/id}","deployments_url":"https://api.github.com/repos/AbfrmBlr/ehcache3/deployments","created_at":"2014-12-29T10:47:44Z","updated_at":"2016-01-19T07:22:30Z","pushed_at":"2016-06-27T17:38:15Z","git_url":"git://github.com/AbfrmBlr/ehcache3.git","ssh_url":"git@github.com:AbfrmBlr/ehcache3.git","clone_url":"https://github.com/AbfrmBlr/ehcache3.git","svn_url":"https://github.com/AbfrmBlr/ehcache3","homepage":"ehcache.org","size":10318,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ehcache:master","ref":"master","sha":"7a0a75b8ad0293996c5c944d5ed5e76aca6ff7de","user":{"login":"ehcache","id":5504982,"avatar_url":"https://avatars.githubusercontent.com/u/5504982?v=3","gravatar_id":"","url":"https://api.github.com/users/ehcache","html_url":"https://github.com/ehcache","followers_url":"https://api.github.com/users/ehcache/followers","following_url":"https://api.github.com/users/ehcache/following{/other_user}","gists_url":"https://api.github.com/users/ehcache/gists{/gist_id}","starred_url":"https://api.github.com/users/ehcache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehcache/subscriptions","organizations_url":"https://api.github.com/users/ehcache/orgs","repos_url":"https://api.github.com/users/ehcache/repos","events_url":"https://api.github.com/users/ehcache/events{/privacy}","received_events_url":"https://api.github.com/users/ehcache/received_events","type":"Organization","site_admin":false},"repo":{"id":17224514,"name":"ehcache3","full_name":"ehcache/ehcache3","owner":{"login":"ehcache","id":5504982,"avatar_url":"https://avatars.githubusercontent.com/u/5504982?v=3","gravatar_id":"","url":"https://api.github.com/users/ehcache","html_url":"https://github.com/ehcache","followers_url":"https://api.github.com/users/ehcache/followers","following_url":"https://api.github.com/users/ehcache/following{/other_user}","gists_url":"https://api.github.com/users/ehcache/gists{/gist_id}","starred_url":"https://api.github.com/users/ehcache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehcache/subscriptions","organizations_url":"https://api.github.com/users/ehcache/orgs","repos_url":"https://api.github.com/users/ehcache/repos","events_url":"https://api.github.com/users/ehcache/events{/privacy}","received_events_url":"https://api.github.com/users/ehcache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ehcache/ehcache3","description":"Ehcache 3.x line ","fork":false,"url":"https://api.github.com/repos/ehcache/ehcache3","forks_url":"https://api.github.com/repos/ehcache/ehcache3/forks","keys_url":"https://api.github.com/repos/ehcache/ehcache3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ehcache/ehcache3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ehcache/ehcache3/teams","hooks_url":"https://api.github.com/repos/ehcache/ehcache3/hooks","issue_events_url":"https://api.github.com/repos/ehcache/ehcache3/issues/events{/number}","events_url":"https://api.github.com/repos/ehcache/ehcache3/events","assignees_url":"https://api.github.com/repos/ehcache/ehcache3/assignees{/user}","branches_url":"https://api.github.com/repos/ehcache/ehcache3/branches{/branch}","tags_url":"https://api.github.com/repos/ehcache/ehcache3/tags","blobs_url":"https://api.github.com/repos/ehcache/ehcache3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ehcache/ehcache3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ehcache/ehcache3/git/refs{/sha}","trees_url":"https://api.github.com/repos/ehcache/ehcache3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ehcache/ehcache3/statuses/{sha}","languages_url":"https://api.github.com/repos/ehcache/ehcache3/languages","stargazers_url":"https://api.github.com/repos/ehcache/ehcache3/stargazers","contributors_url":"https://api.github.com/repos/ehcache/ehcache3/contributors","subscribers_url":"https://api.github.com/repos/ehcache/ehcache3/subscribers","subscription_url":"https://api.github.com/repos/ehcache/ehcache3/subscription","commits_url":"https://api.github.com/repos/ehcache/ehcache3/commits{/sha}","git_commits_url":"https://api.github.com/repos/ehcache/ehcache3/git/commits{/sha}","comments_url":"https://api.github.com/repos/ehcache/ehcache3/comments{/number}","issue_comment_url":"https://api.github.com/repos/ehcache/ehcache3/issues/comments{/number}","contents_url":"https://api.github.com/repos/ehcache/ehcache3/contents/{+path}","compare_url":"https://api.github.com/repos/ehcache/ehcache3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ehcache/ehcache3/merges","archive_url":"https://api.github.com/repos/ehcache/ehcache3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ehcache/ehcache3/downloads","issues_url":"https://api.github.com/repos/ehcache/ehcache3/issues{/number}","pulls_url":"https://api.github.com/repos/ehcache/ehcache3/pulls{/number}","milestones_url":"https://api.github.com/repos/ehcache/ehcache3/milestones{/number}","notifications_url":"https://api.github.com/repos/ehcache/ehcache3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ehcache/ehcache3/labels{/name}","releases_url":"https://api.github.com/repos/ehcache/ehcache3/releases{/id}","deployments_url":"https://api.github.com/repos/ehcache/ehcache3/deployments","created_at":"2014-02-26T20:39:16Z","updated_at":"2016-06-27T06:51:09Z","pushed_at":"2016-06-27T19:30:02Z","git_url":"git://github.com/ehcache/ehcache3.git","ssh_url":"git@github.com:ehcache/ehcache3.git","clone_url":"https://github.com/ehcache/ehcache3.git","svn_url":"https://github.com/ehcache/ehcache3","homepage":"http://www.ehcache.org","size":12612,"stargazers_count":436,"watchers_count":436,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":238,"mirror_url":null,"open_issues_count":89,"forks":238,"open_issues":89,"watchers":436,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ehcache/ehcache3/pulls/1233"},"html":{"href":"https://github.com/ehcache/ehcache3/pull/1233"},"issue":{"href":"https://api.github.com/repos/ehcache/ehcache3/issues/1233"},"comments":{"href":"https://api.github.com/repos/ehcache/ehcache3/issues/1233/comments"},"review_comments":{"href":"https://api.github.com/repos/ehcache/ehcache3/pulls/1233/comments"},"review_comment":{"href":"https://api.github.com/repos/ehcache/ehcache3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ehcache/ehcache3/pulls/1233/commits"},"statuses":{"href":"https://api.github.com/repos/ehcache/ehcache3/statuses/2da4030f58b4a06522e97093dc6295eb791e9971"}}}}
{"actor":{"display_login":"albinsuresh"}}