From 7fd018d3e00d0aff4e561d8d75583f57675f880f Mon Sep 17 00:00:00 2001 From: Mehmet Dogan Date: Fri, 20 Sep 2019 10:11:22 +0300 Subject: [PATCH] Remove legacy Semaphore --- .../HazelcastClientBeanDefinitionParser.java | 4 +- .../HazelcastConfigBeanDefinitionParser.java | 33 +- .../HazelcastInstanceDefinitionParser.java | 4 +- .../spring/HazelcastNamespaceHandler.java | 1 + .../HazelcastTypeBeanDefinitionParser.java | 4 +- .../main/resources/hazelcast-spring-4.0.xsd | 48 +- .../spring/TestFullApplicationContext.java | 25 +- ...ullConfig-applicationContext-hazelcast.xml | 12 +- .../client/cp/internal/CPSubsystemImpl.java | 4 +- .../proxy/ClientRaftProxyFactory.java | 10 +- .../RaftSessionAwareSemaphoreProxy.java | 42 +- .../RaftSessionlessSemaphoreProxy.java | 40 +- .../ClientDynamicClusterConfig.java | 41 +- .../HazelcastClientInstanceImpl.java | 44 +- .../impl/clientside/HazelcastClientProxy.java | 6 - .../DefaultMessageTaskFactoryProvider.java | 69 +-- .../codec/CPSemaphoreAcquireCodec.java | 158 ------- .../CPSemaphoreAvailablePermitsCodec.java | 115 ----- .../protocol/codec/CPSemaphoreInitCodec.java | 123 ----- .../codec/CPSemaphoreReleaseCodec.java | 147 ------ .../codec/ClientCreateProxyCodec.java | 3 +- .../codec/ClientDestroyProxyCodec.java | 3 +- .../DynamicConfigAddSemaphoreConfigCodec.java | 135 ------ .../protocol/codec/SemaphoreAcquireCodec.java | 82 +++- .../codec/SemaphoreAvailablePermitsCodec.java | 26 +- ...geCodec.java => SemaphoreChangeCodec.java} | 20 +- ...ainCodec.java => SemaphoreDrainCodec.java} | 20 +- .../codec/SemaphoreDrainPermitsCodec.java | 108 ----- ...va => SemaphoreGetSemaphoreTypeCodec.java} | 20 +- .../codec/SemaphoreIncreasePermitsCodec.java | 110 ----- .../protocol/codec/SemaphoreInitCodec.java | 24 +- .../codec/SemaphoreReducePermitsCodec.java | 109 ----- .../protocol/codec/SemaphoreReleaseCodec.java | 73 ++- .../codec/SemaphoreTryAcquireCodec.java | 125 ----- .../AddSemaphoreConfigMessageTask.java | 58 --- .../SemaphoreAcquireMessageTask.java | 80 ---- ...SemaphoreAvailablePermitsMessageTasks.java | 80 ---- .../SemaphoreDrainPermitsMessageTask.java | 78 ---- .../SemaphoreIncreasePermitsMessageTask.java | 78 ---- .../semaphore/SemaphoreInitMessageTask.java | 79 ---- .../SemaphoreReducePermitsMessageTask.java | 78 ---- .../SemaphoreReleaseMessageTask.java | 79 ---- .../SemaphoreTryAcquireMessageTask.java | 83 ---- .../protocol/task/semaphore/package-info.java | 21 - .../impl/proxy/ClientSemaphoreProxy.java | 161 ------- .../client/impl/spi/ProxyManager.java | 7 +- .../java/com/hazelcast/config/Config.java | 116 ----- .../config/ConfigDataSerializerHook.java | 1 - .../hazelcast/config/ConfigXmlGenerator.java | 18 +- .../config/MemberDomConfigProcessor.java | 46 +- .../com/hazelcast/config/SemaphoreConfig.java | 278 ------------ .../config/SemaphoreConfigReadOnly.java | 54 --- .../config/YamlMemberDomConfigProcessor.java | 21 +- .../config/cp/CPSubsystemConfig.java | 24 +- ...aphoreConfig.java => SemaphoreConfig.java} | 16 +- .../com/hazelcast/core/HazelcastInstance.java | 14 - .../java/com/hazelcast/cp/CPSubsystem.java | 4 +- .../com/hazelcast/cp/ICountDownLatch.java | 2 +- .../java/com/hazelcast/cp/ISemaphore.java | 41 +- .../cp/internal/CPSubsystemImpl.java | 4 +- .../RaftDataServiceDescriptorProvider.java | 10 +- .../semaphore/AcquireInvocationKey.java | 4 +- .../{RaftSemaphore.java => Semaphore.java} | 16 +- ....java => SemaphoreDataSerializerHook.java} | 6 +- .../semaphore/SemaphoreEndpoint.java | 4 +- ...reRegistry.java => SemaphoreRegistry.java} | 28 +- ...horeService.java => SemaphoreService.java} | 28 +- .../client/AcquirePermitsMessageTask.java | 14 +- .../client/AvailablePermitsMessageTask.java | 14 +- .../client/ChangePermitsMessageTask.java | 14 +- .../client/DrainPermitsMessageTask.java | 14 +- .../client/GetSemaphoreTypeMessageTask.java | 18 +- .../client/InitSemaphoreMessageTask.java | 14 +- .../client/ReleasePermitsMessageTask.java | 14 +- .../operation/AbstractSemaphoreOp.java | 8 +- .../semaphore/operation/AcquirePermitsOp.java | 12 +- .../operation/AvailablePermitsOp.java | 16 +- .../semaphore/operation/ChangePermitsOp.java | 16 +- .../semaphore/operation/DrainPermitsOp.java | 12 +- .../semaphore/operation/InitSemaphoreOp.java | 16 +- .../semaphore/operation/ReleasePermitsOp.java | 12 +- ...y.java => SessionAwareSemaphoreProxy.java} | 8 +- ...xy.java => SessionlessSemaphoreProxy.java} | 8 +- .../unsafe/semaphore/SemaphoreContainer.java | 227 --------- .../SemaphoreDataSerializerHook.java | 116 ----- .../unsafe/semaphore/SemaphoreProxy.java | 183 -------- .../unsafe/semaphore/SemaphoreService.java | 221 --------- .../semaphore/SemaphoreWaitNotifyKey.java | 59 --- .../operations/AcquireBackupOperation.java | 42 -- .../operations/AcquireOperation.java | 75 --- .../operations/AvailableOperation.java | 42 -- .../operations/DrainBackupOperation.java | 42 -- .../semaphore/operations/DrainOperation.java | 53 --- .../operations/IncreaseBackupOperation.java | 42 -- .../operations/IncreaseOperation.java | 53 --- .../operations/InitBackupOperation.java | 42 -- .../semaphore/operations/InitOperation.java | 55 --- .../operations/ReduceBackupOperation.java | 42 -- .../semaphore/operations/ReduceOperation.java | 55 --- .../operations/ReleaseBackupOperation.java | 42 -- .../operations/ReleaseOperation.java | 67 --- .../SemaphoreBackupAwareOperation.java | 42 -- .../operations/SemaphoreBackupOperation.java | 48 -- .../SemaphoreDetachMemberBackupOperation.java | 45 -- .../SemaphoreDetachMemberOperation.java | 110 ----- .../operations/SemaphoreOperation.java | 75 --- .../SemaphoreReplicationOperation.java | 89 ---- .../semaphore/operations/package-info.java | 22 - .../unsafe/semaphore/package-info.java | 27 -- .../instance/impl/HazelcastInstanceImpl.java | 14 +- .../instance/impl/HazelcastInstanceProxy.java | 10 +- .../ClusterWideConfigurationService.java | 17 - .../dynamicconfig/ConfigurationService.java | 16 - .../DynamicCPSubsystemConfig.java | 6 +- .../DynamicConfigurationAwareConfig.java | 53 +-- .../EmptyConfigurationService.java | 11 - .../dynamicconfig/search/ConfigSearch.java | 17 - .../com/hazelcast/internal/jmx/MBeans.java | 27 +- .../osgi/impl/HazelcastOSGiInstanceImpl.java | 6 - .../security/permission/ActionConstants.java | 15 +- .../impl/ServiceManagerImpl.java | 2 - .../services/com.hazelcast.DataSerializerHook | 3 +- .../main/resources/hazelcast-config-4.0.xsd | 54 +-- .../src/main/resources/hazelcast-default.xml | 6 - .../src/main/resources/hazelcast-default.yaml | 6 - .../main/resources/hazelcast-full-example.xml | 35 +- .../resources/hazelcast-full-example.yaml | 24 - .../ClientRegressionWithMockNetworkTest.java | 2 +- .../ClientSemaphoreThreadedTest.java | 4 +- .../client/semaphore/ClientSemaphoreTest.java | 277 ----------- ...SemaphoreSplitBrainProtectionReadTest.java | 60 --- ...emaphoreSplitBrainProtectionWriteTest.java | 60 --- .../config/AbstractConfigBuilderTest.java | 3 - .../config/ConfigCompatibilityChecker.java | 36 +- .../config/ConfigXmlGeneratorTest.java | 24 +- .../config/InvalidConfigurationTest.java | 34 -- .../hazelcast/config/SemaphoreConfigTest.java | 64 --- .../config/XMLConfigBuilderTest.java | 34 +- ...mlConfigImportVariableReplacementTest.java | 13 +- .../config/YamlConfigBuilderTest.java | 26 +- ...mlConfigImportVariableReplacementTest.java | 11 +- .../hazelcast/core/DistributedObjectTest.java | 7 - .../AbstractSemaphoreAdvancedTest.java | 42 +- .../AbstractSemaphoreFailureTest.java | 60 +-- ...bstractSessionAwareSemaphoreBasicTest.java | 12 +- ...AbstractSessionlessSemaphoreBasicTest.java | 8 +- .../RaftSessionAwareSemaphoreBasicTest.java | 4 +- .../RaftSessionAwareSemaphoreFailureTest.java | 2 +- .../RaftSessionlessSemaphoreBasicTest.java | 4 +- .../RaftSessionlessSemaphoreFailureTest.java | 2 +- ...edTest.java => SemaphoreAdvancedTest.java} | 16 +- ...ureTest.java => SemaphoreFailureTest.java} | 6 +- ...tTest.java => SemaphoreLongAwaitTest.java} | 10 +- ...otTest.java => SemaphoreSnapshotTest.java} | 6 +- ...Test.java => SemaphoreSplitBrainTest.java} | 2 +- .../UnsafeSemaphoreAdvancedTest.java | 4 +- .../semaphore/UnsafeSemaphoreFailureTest.java | 4 +- .../UnsafeSessionAwareSemaphoreBasicTest.java | 12 +- .../UnsafeSessionlessSemaphoreBasicTest.java | 4 +- .../semaphore/SemaphoreAdvancedTest.java | 163 ------- .../SemaphoreBasicDistributedTest.java | 34 -- .../semaphore/SemaphoreBasicLocalTest.java | 34 -- .../unsafe/semaphore/SemaphoreBasicTest.java | 429 ------------------ .../semaphore/SemaphoreSplitBrainTest.java | 76 ---- .../dynamicconfig/ConfigSearchTest.java | 47 -- .../dynamicconfig/DynamicConfigTest.java | 22 - .../internal/jmx/MBeanDestroyTest.java | 20 +- .../com/hazelcast/internal/jmx/MBeanTest.java | 9 - .../osgi/HazelcastOSGiInstanceTest.java | 8 +- .../partition/PartitionControlledIdTest.java | 70 ++- .../permission/ActionConstantsTest.java | 10 +- .../AbstractSplitBrainProtectionTest.java | 18 +- ...SemaphoreSplitBrainProtectionReadTest.java | 76 ---- ...emaphoreSplitBrainProtectionWriteTest.java | 201 -------- .../hazelcast-fullconfig-without-network.xml | 15 +- .../hazelcast-fullconfig-without-network.yaml | 7 - 176 files changed, 699 insertions(+), 7246 deletions(-) delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreAcquireCodec.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreAvailablePermitsCodec.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreInitCodec.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreReleaseCodec.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/DynamicConfigAddSemaphoreConfigCodec.java rename hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/{CPSemaphoreChangeCodec.java => SemaphoreChangeCodec.java} (91%) rename hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/{CPSemaphoreDrainCodec.java => SemaphoreDrainCodec.java} (90%) delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreDrainPermitsCodec.java rename hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/{CPSemaphoreGetSemaphoreTypeCodec.java => SemaphoreGetSemaphoreTypeCodec.java} (86%) delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreIncreasePermitsCodec.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreReducePermitsCodec.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreTryAcquireCodec.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/dynamicconfig/AddSemaphoreConfigMessageTask.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreAcquireMessageTask.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreAvailablePermitsMessageTasks.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreDrainPermitsMessageTask.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreIncreasePermitsMessageTask.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreInitMessageTask.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreReducePermitsMessageTask.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreReleaseMessageTask.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreTryAcquireMessageTask.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/package-info.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/client/impl/proxy/ClientSemaphoreProxy.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/config/SemaphoreConfig.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/config/SemaphoreConfigReadOnly.java rename hazelcast/src/main/java/com/hazelcast/config/cp/{CPSemaphoreConfig.java => SemaphoreConfig.java} (87%) rename hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphore.java => Semaphore.java} (97%) rename hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphoreDataSerializerHook.java => SemaphoreDataSerializerHook.java} (94%) rename hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphoreRegistry.java => SemaphoreRegistry.java} (79%) rename hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphoreService.java => SemaphoreService.java} (87%) rename hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/{RaftSessionAwareSemaphoreProxy.java => SessionAwareSemaphoreProxy.java} (96%) rename hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/{RaftSessionlessSemaphoreProxy.java => SessionlessSemaphoreProxy.java} (94%) delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreContainer.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreDataSerializerHook.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreProxy.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreService.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreWaitNotifyKey.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AcquireBackupOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AcquireOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AvailableOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/DrainBackupOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/DrainOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/IncreaseBackupOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/IncreaseOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/InitBackupOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/InitOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReduceBackupOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReduceOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReleaseBackupOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReleaseOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreBackupAwareOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreBackupOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreDetachMemberBackupOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreDetachMemberOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreReplicationOperation.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/package-info.java delete mode 100644 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/package-info.java rename hazelcast/src/test/java/com/hazelcast/client/{ => cp/internal/datastructures}/semaphore/ClientSemaphoreThreadedTest.java (96%) delete mode 100644 hazelcast/src/test/java/com/hazelcast/client/semaphore/ClientSemaphoreTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/client/splitbrainprotection/semaphore/ClientSemaphoreSplitBrainProtectionReadTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/client/splitbrainprotection/semaphore/ClientSemaphoreSplitBrainProtectionWriteTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/config/SemaphoreConfigTest.java rename hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphoreAdvancedTest.java => SemaphoreAdvancedTest.java} (88%) rename hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphoreFailureTest.java => SemaphoreFailureTest.java} (85%) rename hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphoreLongAwaitTest.java => SemaphoreLongAwaitTest.java} (89%) rename hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphoreSnapshotTest.java => SemaphoreSnapshotTest.java} (91%) rename hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/semaphore/{RaftSemaphoreSplitBrainTest.java => SemaphoreSplitBrainTest.java} (97%) delete mode 100644 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreAdvancedTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreBasicDistributedTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreBasicLocalTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreBasicTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreSplitBrainTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/splitbrainprotection/semaphore/SemaphoreSplitBrainProtectionReadTest.java delete mode 100644 hazelcast/src/test/java/com/hazelcast/splitbrainprotection/semaphore/SemaphoreSplitBrainProtectionWriteTest.java diff --git a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastClientBeanDefinitionParser.java b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastClientBeanDefinitionParser.java index 888d1abc82723..b066ceca26999 100644 --- a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastClientBeanDefinitionParser.java +++ b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastClientBeanDefinitionParser.java @@ -62,7 +62,7 @@ import static com.hazelcast.config.DomConfigHelper.cleanNodeName; import static com.hazelcast.config.DomConfigHelper.getBooleanValue; import static com.hazelcast.config.DomConfigHelper.getIntegerValue; -import static com.hazelcast.spring.HazelcastInstanceDefinitionParser.CP_SUBSYSTEM_SUFFX; +import static com.hazelcast.spring.HazelcastInstanceDefinitionParser.CP_SUBSYSTEM_SUFFIX; import static com.hazelcast.internal.util.StringUtil.upperCaseInternal; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition; import static org.springframework.util.Assert.isTrue; @@ -102,7 +102,7 @@ private void registerCPSubsystemBean(Element element, ParserContext parserContex cpBeanDefBuilder.setLazyInit(true); BeanDefinitionHolder holder = - new BeanDefinitionHolder(cpBeanDefBuilder.getBeanDefinition(), instanceBeanRef + CP_SUBSYSTEM_SUFFX); + new BeanDefinitionHolder(cpBeanDefBuilder.getBeanDefinition(), instanceBeanRef + CP_SUBSYSTEM_SUFFIX); registerBeanDefinition(holder, parserContext.getRegistry()); } diff --git a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastConfigBeanDefinitionParser.java b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastConfigBeanDefinitionParser.java index 9ff7db6ef0d26..aa7073dd84e42 100644 --- a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastConfigBeanDefinitionParser.java +++ b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastConfigBeanDefinitionParser.java @@ -97,7 +97,6 @@ import com.hazelcast.config.ScheduledExecutorConfig; import com.hazelcast.config.SecurityConfig; import com.hazelcast.config.SecurityInterceptorConfig; -import com.hazelcast.config.SemaphoreConfig; import com.hazelcast.config.ServerSocketEndpointConfig; import com.hazelcast.config.ServiceConfig; import com.hazelcast.config.ServicesConfig; @@ -113,7 +112,7 @@ import com.hazelcast.config.WanReplicationConfig; import com.hazelcast.config.WanReplicationRef; import com.hazelcast.config.WanSyncConfig; -import com.hazelcast.config.cp.CPSemaphoreConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.config.cp.RaftAlgorithmConfig; @@ -202,7 +201,6 @@ private class SpringXmlConfigBuilder extends SpringXmlBuilderHelper { private ManagedMap atomicLongManagedMap; private ManagedMap atomicReferenceManagedMap; private ManagedMap reliableTopicManagedMap; - private ManagedMap semaphoreManagedMap; private ManagedMap listManagedMap; private ManagedMap setManagedMap; private ManagedMap topicManagedMap; @@ -232,7 +230,6 @@ private class SpringXmlConfigBuilder extends SpringXmlBuilderHelper { this.atomicLongManagedMap = createManagedMap("atomicLongConfigs"); this.atomicReferenceManagedMap = createManagedMap("atomicReferenceConfigs"); this.reliableTopicManagedMap = createManagedMap("reliableTopicConfigs"); - this.semaphoreManagedMap = createManagedMap("semaphoreConfigs"); this.listManagedMap = createManagedMap("listConfigs"); this.setManagedMap = createManagedMap("setConfigs"); this.topicManagedMap = createManagedMap("topicConfigs"); @@ -293,8 +290,6 @@ public void handleConfig(Element element) { handleAtomicReference(node); } else if ("reliable-topic".equals(nodeName)) { handleReliableTopic(node); - } else if ("semaphore".equals(nodeName)) { - handleSemaphore(node); } else if ("map".equals(nodeName)) { handleMap(node); } else if ("cache".equals(nodeName)) { @@ -403,7 +398,7 @@ private void handleCPSubSystem(Node node) { raftAlgorithmConfigBuilder.getBeanDefinition()); } else if ("semaphores".equals(nodeName)) { ManagedMap semaphores = new ManagedMap(); - handleCPSemaphores(semaphores, child); + handleSemaphores(semaphores, child); cpSubsystemConfigBuilder.addPropertyValue("SemaphoreConfigs", semaphores); } else if ("locks".equals(nodeName)) { ManagedMap locks = new ManagedMap(); @@ -424,21 +419,21 @@ private void handleCPSubSystem(Node node) { configBuilder.addPropertyValue("CPSubsystemConfig", cpSubsystemConfigBuilder.getBeanDefinition()); } - private void handleCPSemaphores(ManagedMap cpSemaphores, Node node) { + private void handleSemaphores(ManagedMap semaphores, Node node) { for (Node child : childElements(node)) { - BeanDefinitionBuilder cpSemaphoreConfigBuilder = createBeanBuilder(CPSemaphoreConfig.class); + BeanDefinitionBuilder semaphoreConfigBuilder = createBeanBuilder(SemaphoreConfig.class); for (Node subChild : childElements(child)) { String nodeName = cleanNodeName(subChild); String value = getTextContent(subChild).trim(); if ("name".equals(nodeName)) { - cpSemaphoreConfigBuilder.addPropertyValue("name", value); + semaphoreConfigBuilder.addPropertyValue("name", value); } else if ("jdk-compatible".equals(nodeName)) { - cpSemaphoreConfigBuilder.addPropertyValue("JDKCompatible", getBooleanValue(value)); + semaphoreConfigBuilder.addPropertyValue("JDKCompatible", getBooleanValue(value)); } } - AbstractBeanDefinition beanDefinition = cpSemaphoreConfigBuilder.getBeanDefinition(); + AbstractBeanDefinition beanDefinition = semaphoreConfigBuilder.getBeanDefinition(); String name = (String) beanDefinition.getPropertyValues().get("name"); - cpSemaphores.put(name, beanDefinition); + semaphores.put(name, beanDefinition); } } @@ -1064,18 +1059,6 @@ public void handleReliableTopic(Node node) { reliableTopicManagedMap.put(getAttribute(node, "name"), builder.getBeanDefinition()); } - public void handleSemaphore(Node node) { - BeanDefinitionBuilder builder = createBeanBuilder(SemaphoreConfig.class); - fillAttributeValues(node, builder); - for (Node childNode : childElements(node)) { - String nodeName = cleanNodeName(childNode); - if ("split-brain-protection-ref".equals(nodeName)) { - builder.addPropertyValue("splitBrainProtectionName", getTextContent(childNode)); - } - } - semaphoreManagedMap.put(getAttribute(node, "name"), builder.getBeanDefinition()); - } - public void handleLock(Node node) { BeanDefinitionBuilder lockConfigBuilder = createBeanBuilder(LockConfig.class); fillAttributeValues(node, lockConfigBuilder); diff --git a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastInstanceDefinitionParser.java b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastInstanceDefinitionParser.java index 334086f728a3e..f1ff4e678ab99 100644 --- a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastInstanceDefinitionParser.java +++ b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastInstanceDefinitionParser.java @@ -53,7 +53,7 @@ */ public class HazelcastInstanceDefinitionParser extends AbstractHazelcastBeanDefinitionParser { - static final String CP_SUBSYSTEM_SUFFX = "@cp-subsystem"; + static final String CP_SUBSYSTEM_SUFFIX = "@cp-subsystem"; @Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { @@ -100,7 +100,7 @@ private void registerCPSubsystemBean(Element element) { cpBeanDefBuilder.setFactoryMethodOnBean("getCPSubsystem", instanceBeanRef); BeanDefinitionHolder holder = - new BeanDefinitionHolder(cpBeanDefBuilder.getBeanDefinition(), instanceBeanRef + CP_SUBSYSTEM_SUFFX); + new BeanDefinitionHolder(cpBeanDefBuilder.getBeanDefinition(), instanceBeanRef + CP_SUBSYSTEM_SUFFIX); registerBeanDefinition(holder, parserContext.getRegistry()); } } diff --git a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastNamespaceHandler.java b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastNamespaceHandler.java index 7e6e6420828fa..b7ca3b3ce5ce8 100644 --- a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastNamespaceHandler.java +++ b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastNamespaceHandler.java @@ -51,6 +51,7 @@ public class HazelcastNamespaceHandler extends NamespaceHandlerSupport { private static final String PNCOUNTER = "PNCounter"; static { + CP_TYPES.add(SEMAPHORE); CP_TYPES.add(COUNT_DOWN_LATCH); } diff --git a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastTypeBeanDefinitionParser.java b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastTypeBeanDefinitionParser.java index 78d123f970793..2342f5307db29 100644 --- a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastTypeBeanDefinitionParser.java +++ b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastTypeBeanDefinitionParser.java @@ -24,7 +24,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; -import static com.hazelcast.spring.HazelcastInstanceDefinitionParser.CP_SUBSYSTEM_SUFFX; +import static com.hazelcast.spring.HazelcastInstanceDefinitionParser.CP_SUBSYSTEM_SUFFIX; /** * BeanDefinitionParser for Type Configuration of Hazelcast Types like map, queue, topic etc. @@ -72,7 +72,7 @@ public void handle(Element element) { } String instanceRef = getTextContent(instanceRefNode); if (HazelcastNamespaceHandler.CP_TYPES.contains(type)) { - builder.getRawBeanDefinition().setFactoryBeanName(instanceRef + CP_SUBSYSTEM_SUFFX); + builder.getRawBeanDefinition().setFactoryBeanName(instanceRef + CP_SUBSYSTEM_SUFFIX); } else { builder.getRawBeanDefinition().setFactoryBeanName(instanceRef); } diff --git a/hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd b/hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd index 4724fcb35d2a4..cdfd13140ac91 100644 --- a/hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd +++ b/hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd @@ -419,50 +419,6 @@ - - - - - - - Adds the Split Brain Protection for this data-structure which you configure using the split-brain-protection element. - You should set the split-brain-protection-ref's value as the split brain protection's name. - - - - - - - - - The thread count to which the concurrent access is limited. For example, if you set - it to "3", concurrent access to the object is limited to 3 threads. - - - - - - - Number of synchronous backups. For example, if 1 is set as the backup-count, - then the items in the ringbuffer are copied to one other JVM for fail-safety. - `backup-count` + `async-backup-count` cannot be bigger than maximum - backup count which is `6`. Valid numbers are 0 (no backup), 1, 2 ... 6. - - - - - - - Number of asynchronous backups. For example, if 1 is set as the backup-count, - then the items in the ringbuffer are copied to one other JVM for fail-safety. - `backup-count` + `async-backup-count` cannot be bigger than maximum - backup count which is `6`. Valid numbers are 0 (no backup), 1, 2 ... 6. - - - - - @@ -4479,7 +4435,7 @@ - + @@ -4562,7 +4518,7 @@ - + diff --git a/hazelcast-spring/src/test/java/com/hazelcast/spring/TestFullApplicationContext.java b/hazelcast-spring/src/test/java/com/hazelcast/spring/TestFullApplicationContext.java index 84f157806a6df..8ef2dfafa57bb 100644 --- a/hazelcast-spring/src/test/java/com/hazelcast/spring/TestFullApplicationContext.java +++ b/hazelcast-spring/src/test/java/com/hazelcast/spring/TestFullApplicationContext.java @@ -91,7 +91,6 @@ import com.hazelcast.config.SSLConfig; import com.hazelcast.config.ScheduledExecutorConfig; import com.hazelcast.config.SecurityConfig; -import com.hazelcast.config.SemaphoreConfig; import com.hazelcast.config.SerializationConfig; import com.hazelcast.config.SerializerConfig; import com.hazelcast.config.ServiceConfig; @@ -109,7 +108,7 @@ import com.hazelcast.config.WanReplicationConfig; import com.hazelcast.config.WanReplicationRef; import com.hazelcast.config.WanSyncConfig; -import com.hazelcast.config.cp.CPSemaphoreConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.config.cp.RaftAlgorithmConfig; @@ -617,16 +616,6 @@ public void testAtomicReferenceConfig() { assertEquals(4223, mergePolicyConfig.getBatchSize()); } - @Test - public void testSemaphoreConfig() { - SemaphoreConfig testSemaphore = config.getSemaphoreConfig("testSemaphore"); - assertNotNull(testSemaphore); - assertEquals("testSemaphore", testSemaphore.getName()); - assertEquals(1, testSemaphore.getBackupCount()); - assertEquals(1, testSemaphore.getAsyncBackupCount()); - assertEquals(10, testSemaphore.getInitialPermits()); - } - @Test public void testReliableTopicConfig() { ReliableTopicConfig testReliableTopic = config.getReliableTopicConfig("testReliableTopic"); @@ -1425,12 +1414,12 @@ public void testCPSubsystemConfig() { assertEquals(250, raftAlgorithmConfig.getCommitIndexAdvanceCountToSnapshot()); assertEquals(75, raftAlgorithmConfig.getUncommittedEntryCountToRejectNewAppends()); assertEquals(50, raftAlgorithmConfig.getAppendRequestBackoffTimeoutInMillis()); - CPSemaphoreConfig cpSemaphoreConfig1 = cpSubsystemConfig.findSemaphoreConfig("sem1"); - CPSemaphoreConfig cpSemaphoreConfig2 = cpSubsystemConfig.findSemaphoreConfig("sem2"); - assertNotNull(cpSemaphoreConfig1); - assertNotNull(cpSemaphoreConfig2); - assertTrue(cpSemaphoreConfig1.isJDKCompatible()); - assertFalse(cpSemaphoreConfig2.isJDKCompatible()); + SemaphoreConfig semaphoreConfig1 = cpSubsystemConfig.findSemaphoreConfig("sem1"); + SemaphoreConfig semaphoreConfig2 = cpSubsystemConfig.findSemaphoreConfig("sem2"); + assertNotNull(semaphoreConfig1); + assertNotNull(semaphoreConfig2); + assertTrue(semaphoreConfig1.isJDKCompatible()); + assertFalse(semaphoreConfig2.isJDKCompatible()); FencedLockConfig lockConfig1 = cpSubsystemConfig.findLockConfig("lock1"); FencedLockConfig lockConfig2 = cpSubsystemConfig.findLockConfig("lock2"); assertNotNull(lockConfig1); diff --git a/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullConfig-applicationContext-hazelcast.xml b/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullConfig-applicationContext-hazelcast.xml index 8b6c6947e3444..725b06707ee80 100644 --- a/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullConfig-applicationContext-hazelcast.xml +++ b/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullConfig-applicationContext-hazelcast.xml @@ -360,10 +360,6 @@ PassThroughMergePolicy - - my-split-brain-protection - - @@ -841,14 +837,14 @@ 50 - + sem1 true - - + + sem2 false - + diff --git a/hazelcast/src/main/java/com/hazelcast/client/cp/internal/CPSubsystemImpl.java b/hazelcast/src/main/java/com/hazelcast/client/cp/internal/CPSubsystemImpl.java index 02ec999d839b6..436f20d479943 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/cp/internal/CPSubsystemImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/client/cp/internal/CPSubsystemImpl.java @@ -30,7 +30,7 @@ import com.hazelcast.cp.internal.datastructures.atomicref.RaftAtomicRefService; import com.hazelcast.cp.internal.datastructures.countdownlatch.CountDownLatchService; import com.hazelcast.cp.internal.datastructures.lock.RaftLockService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.lock.FencedLock; import com.hazelcast.cp.session.CPSessionManagementService; @@ -71,7 +71,7 @@ public FencedLock getLock(String name) { @Override public ISemaphore getSemaphore(String name) { - return proxyFactory.createProxy(RaftSemaphoreService.SERVICE_NAME, name); + return proxyFactory.createProxy(SemaphoreService.SERVICE_NAME, name); } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/proxy/ClientRaftProxyFactory.java b/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/proxy/ClientRaftProxyFactory.java index 56c03f2eab649..1c8375de7da5b 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/proxy/ClientRaftProxyFactory.java +++ b/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/proxy/ClientRaftProxyFactory.java @@ -25,7 +25,7 @@ import com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl; import com.hazelcast.client.impl.protocol.ClientMessage; import com.hazelcast.client.impl.protocol.codec.CPGroupCreateCPGroupCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreGetSemaphoreTypeCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreGetSemaphoreTypeCodec; import com.hazelcast.client.impl.spi.ClientContext; import com.hazelcast.client.impl.spi.impl.ClientInvocation; import com.hazelcast.core.DistributedObject; @@ -35,7 +35,7 @@ import com.hazelcast.cp.internal.datastructures.atomicref.RaftAtomicRefService; import com.hazelcast.cp.internal.datastructures.countdownlatch.CountDownLatchService; import com.hazelcast.cp.internal.datastructures.lock.RaftLockService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.lock.FencedLock; import java.util.concurrent.ConcurrentHashMap; @@ -77,7 +77,7 @@ public T createProxy(String serviceName, String pr return (T) new CountDownLatchProxy(context, groupId, proxyName, objectName); } else if (serviceName.equals(RaftLockService.SERVICE_NAME)) { return (T) createFencedLock(groupId, proxyName, objectName); - } else if (serviceName.equals(RaftSemaphoreService.SERVICE_NAME)) { + } else if (serviceName.equals(SemaphoreService.SERVICE_NAME)) { return (T) createSemaphore(groupId, proxyName, objectName); } else { throw new IllegalArgumentException(); @@ -108,9 +108,9 @@ private FencedLock createFencedLock(RaftGroupId groupId, String proxyName, Strin } private ISemaphore createSemaphore(RaftGroupId groupId, String proxyName, String objectName) { - ClientMessage request = CPSemaphoreGetSemaphoreTypeCodec.encodeRequest(proxyName); + ClientMessage request = SemaphoreGetSemaphoreTypeCodec.encodeRequest(proxyName); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - boolean jdkCompatible = CPSemaphoreGetSemaphoreTypeCodec.decodeResponse(response).response; + boolean jdkCompatible = SemaphoreGetSemaphoreTypeCodec.decodeResponse(response).response; return jdkCompatible ? new RaftSessionlessSemaphoreProxy(context, groupId, proxyName, objectName) diff --git a/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionAwareSemaphoreProxy.java b/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionAwareSemaphoreProxy.java index d7b99d922a611..0bad90f069070 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionAwareSemaphoreProxy.java +++ b/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionAwareSemaphoreProxy.java @@ -20,26 +20,26 @@ import com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl; import com.hazelcast.client.impl.protocol.ClientMessage; import com.hazelcast.client.impl.protocol.codec.CPGroupDestroyCPObjectCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreAcquireCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreAvailablePermitsCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreChangeCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreDrainCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreInitCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreReleaseCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreAcquireCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreAvailablePermitsCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreChangeCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreDrainCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreInitCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreReleaseCodec; import com.hazelcast.client.impl.spi.ClientContext; import com.hazelcast.client.impl.spi.ClientProxy; import com.hazelcast.client.impl.spi.impl.ClientInvocation; import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.CPGroupId; import com.hazelcast.cp.internal.RaftGroupId; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.session.SessionExpiredException; import com.hazelcast.internal.util.Clock; import java.util.UUID; import java.util.concurrent.TimeUnit; -import static com.hazelcast.cp.internal.datastructures.semaphore.proxy.RaftSessionAwareSemaphoreProxy.DRAIN_SESSION_ACQ_COUNT; +import static com.hazelcast.cp.internal.datastructures.semaphore.proxy.SessionAwareSemaphoreProxy.DRAIN_SESSION_ACQ_COUNT; import static com.hazelcast.cp.internal.session.AbstractProxySessionManager.NO_SESSION_ID; import static com.hazelcast.internal.util.Preconditions.checkNotNegative; import static com.hazelcast.internal.util.Preconditions.checkPositive; @@ -57,7 +57,7 @@ public class RaftSessionAwareSemaphoreProxy extends ClientProxy implements ISema private final String objectName; public RaftSessionAwareSemaphoreProxy(ClientContext context, RaftGroupId groupId, String proxyName, String objectName) { - super(RaftSemaphoreService.SERVICE_NAME, proxyName, context); + super(SemaphoreService.SERVICE_NAME, proxyName, context); this.sessionManager = getClient().getProxySessionManager(); this.groupId = groupId; this.objectName = objectName; @@ -67,10 +67,10 @@ public RaftSessionAwareSemaphoreProxy(ClientContext context, RaftGroupId groupId public boolean init(int permits) { checkNotNegative(permits, "Permits must be non-negative!"); - ClientMessage request = CPSemaphoreInitCodec.encodeRequest(groupId, objectName, permits); + ClientMessage request = SemaphoreInitCodec.encodeRequest(groupId, objectName, permits); HazelcastClientInstanceImpl client = getClient(); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - return CPSemaphoreInitCodec.decodeResponse(response).response; + return SemaphoreInitCodec.decodeResponse(response).response; } @Override @@ -87,7 +87,7 @@ public void acquire(int permits) { for (;;) { long sessionId = sessionManager.acquireSession(this.groupId, permits); try { - ClientMessage request = CPSemaphoreAcquireCodec.encodeRequest(groupId, objectName, sessionId, threadId, + ClientMessage request = SemaphoreAcquireCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid, permits, -1); HazelcastClientInstanceImpl client = getClient(); new ClientInvocation(client, request, objectName).invoke().join(); @@ -124,11 +124,11 @@ public boolean tryAcquire(int permits, long timeout, TimeUnit unit) { start = Clock.currentTimeMillis(); long sessionId = sessionManager.acquireSession(this.groupId, permits); try { - ClientMessage request = CPSemaphoreAcquireCodec.encodeRequest(groupId, objectName, sessionId, threadId, + ClientMessage request = SemaphoreAcquireCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid, permits, timeoutMs); HazelcastClientInstanceImpl client = getClient(); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - boolean acquired = CPSemaphoreAcquireCodec.decodeResponse(response).response; + boolean acquired = SemaphoreAcquireCodec.decodeResponse(response).response; if (!acquired) { sessionManager.releaseSession(this.groupId, sessionId, permits); } @@ -159,7 +159,7 @@ public void release(int permits) { long threadId = getThreadId(); UUID invocationUid = newUnsecureUUID(); try { - ClientMessage request = CPSemaphoreReleaseCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid, + ClientMessage request = SemaphoreReleaseCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid, permits); HazelcastClientInstanceImpl client = getClient(); new ClientInvocation(client, request, objectName).invoke().join(); @@ -173,10 +173,10 @@ public void release(int permits) { @Override public int availablePermits() { - ClientMessage request = CPSemaphoreAvailablePermitsCodec.encodeRequest(groupId, objectName); + ClientMessage request = SemaphoreAvailablePermitsCodec.encodeRequest(groupId, objectName); HazelcastClientInstanceImpl client = getClient(); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - return CPSemaphoreAvailablePermitsCodec.decodeResponse(response).response; + return SemaphoreAvailablePermitsCodec.decodeResponse(response).response; } @Override @@ -187,11 +187,11 @@ public int drainPermits() { for (;;) { long sessionId = sessionManager.acquireSession(this.groupId, DRAIN_SESSION_ACQ_COUNT); try { - ClientMessage request = CPSemaphoreDrainCodec.encodeRequest(groupId, objectName, sessionId, threadId, + ClientMessage request = SemaphoreDrainCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid); HazelcastClientInstanceImpl client = getClient(); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - return CPSemaphoreDrainCodec.decodeResponse(response).response; + return SemaphoreDrainCodec.decodeResponse(response).response; } catch (SessionExpiredException e) { sessionManager.invalidateSession(this.groupId, sessionId); } @@ -214,7 +214,7 @@ public void reducePermits(int reduction) { UUID invocationUid = newUnsecureUUID(); try { - ClientMessage request = CPSemaphoreChangeCodec.encodeRequest(groupId, objectName, sessionId, threadId, + ClientMessage request = SemaphoreChangeCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid, -reduction); new ClientInvocation(getClient(), request, objectName).invoke().join(); } catch (SessionExpiredException e) { @@ -241,7 +241,7 @@ public void increasePermits(int increase) { UUID invocationUid = newUnsecureUUID(); try { - ClientMessage request = CPSemaphoreChangeCodec.encodeRequest(groupId, objectName, sessionId, threadId, + ClientMessage request = SemaphoreChangeCodec.encodeRequest(groupId, objectName, sessionId, threadId, invocationUid, increase); new ClientInvocation(getClient(), request, objectName).invoke().join(); } catch (SessionExpiredException e) { diff --git a/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionlessSemaphoreProxy.java b/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionlessSemaphoreProxy.java index dae5bf7704488..8fedd22dc1da4 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionlessSemaphoreProxy.java +++ b/hazelcast/src/main/java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionlessSemaphoreProxy.java @@ -20,19 +20,19 @@ import com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl; import com.hazelcast.client.impl.protocol.ClientMessage; import com.hazelcast.client.impl.protocol.codec.CPGroupDestroyCPObjectCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreAcquireCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreAvailablePermitsCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreChangeCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreDrainCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreInitCodec; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreReleaseCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreAcquireCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreAvailablePermitsCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreChangeCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreDrainCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreInitCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreReleaseCodec; import com.hazelcast.client.impl.spi.ClientContext; import com.hazelcast.client.impl.spi.ClientProxy; import com.hazelcast.client.impl.spi.impl.ClientInvocation; import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.CPGroupId; import com.hazelcast.cp.internal.RaftGroupId; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -53,7 +53,7 @@ public class RaftSessionlessSemaphoreProxy extends ClientProxy implements ISemap private final String objectName; public RaftSessionlessSemaphoreProxy(ClientContext context, RaftGroupId groupId, String proxyName, String objectName) { - super(RaftSemaphoreService.SERVICE_NAME, proxyName, context); + super(SemaphoreService.SERVICE_NAME, proxyName, context); this.sessionManager = getClient().getProxySessionManager(); this.groupId = groupId; this.objectName = objectName; @@ -63,10 +63,10 @@ public RaftSessionlessSemaphoreProxy(ClientContext context, RaftGroupId groupId, public boolean init(int permits) { checkNotNegative(permits, "Permits must be non-negative!"); - ClientMessage request = CPSemaphoreInitCodec.encodeRequest(groupId, objectName, permits); + ClientMessage request = SemaphoreInitCodec.encodeRequest(groupId, objectName, permits); HazelcastClientInstanceImpl client = getClient(); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - return CPSemaphoreInitCodec.decodeResponse(response).response; + return SemaphoreInitCodec.decodeResponse(response).response; } @Override @@ -81,7 +81,7 @@ public void acquire(int permits) { long clusterWideThreadId = sessionManager.getOrCreateUniqueThreadId(groupId); UUID invocationUid = newUnsecureUUID(); - ClientMessage request = CPSemaphoreAcquireCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, + ClientMessage request = SemaphoreAcquireCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid, permits, -1); HazelcastClientInstanceImpl client = getClient(); new ClientInvocation(client, request, objectName).invoke().join(); @@ -110,11 +110,11 @@ public boolean tryAcquire(int permits, long timeout, TimeUnit unit) { UUID invocationUid = newUnsecureUUID(); long timeoutMs = max(0, unit.toMillis(timeout)); - ClientMessage request = CPSemaphoreAcquireCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, + ClientMessage request = SemaphoreAcquireCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid, permits, timeoutMs); HazelcastClientInstanceImpl client = getClient(); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - return CPSemaphoreAcquireCodec.decodeResponse(response).response; + return SemaphoreAcquireCodec.decodeResponse(response).response; } @Override @@ -129,7 +129,7 @@ public void release(int permits) { long clusterWideThreadId = sessionManager.getOrCreateUniqueThreadId(groupId); UUID invocationUid = newUnsecureUUID(); - ClientMessage request = CPSemaphoreReleaseCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, + ClientMessage request = SemaphoreReleaseCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid, permits); HazelcastClientInstanceImpl client = getClient(); new ClientInvocation(client, request, objectName).invoke().join(); @@ -137,10 +137,10 @@ public void release(int permits) { @Override public int availablePermits() { - ClientMessage request = CPSemaphoreAvailablePermitsCodec.encodeRequest(groupId, objectName); + ClientMessage request = SemaphoreAvailablePermitsCodec.encodeRequest(groupId, objectName); HazelcastClientInstanceImpl client = getClient(); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - return CPSemaphoreAvailablePermitsCodec.decodeResponse(response).response; + return SemaphoreAvailablePermitsCodec.decodeResponse(response).response; } @Override @@ -148,11 +148,11 @@ public int drainPermits() { long clusterWideThreadId = sessionManager.getOrCreateUniqueThreadId(groupId); UUID invocationUid = newUnsecureUUID(); - ClientMessage request = CPSemaphoreDrainCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, + ClientMessage request = SemaphoreDrainCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid); HazelcastClientInstanceImpl client = getClient(); ClientMessage response = new ClientInvocation(client, request, objectName).invoke().join(); - return CPSemaphoreDrainCodec.decodeResponse(response).response; + return SemaphoreDrainCodec.decodeResponse(response).response; } @Override @@ -165,7 +165,7 @@ public void reducePermits(int reduction) { long clusterWideThreadId = sessionManager.getOrCreateUniqueThreadId(groupId); UUID invocationUid = newUnsecureUUID(); - ClientMessage request = CPSemaphoreChangeCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, + ClientMessage request = SemaphoreChangeCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid, -reduction); new ClientInvocation(getClient(), request, objectName).invoke().join(); } @@ -180,7 +180,7 @@ public void increasePermits(int increase) { long clusterWideThreadId = sessionManager.getOrCreateUniqueThreadId(groupId); UUID invocationUid = newUnsecureUUID(); - ClientMessage request = CPSemaphoreChangeCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, + ClientMessage request = SemaphoreChangeCodec.encodeRequest(groupId, objectName, NO_SESSION_ID, clusterWideThreadId, invocationUid, increase); new ClientInvocation(getClient(), request, objectName).invoke().join(); } diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/ClientDynamicClusterConfig.java b/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/ClientDynamicClusterConfig.java index 53eb9536e4295..af67a1e36c16e 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/ClientDynamicClusterConfig.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/ClientDynamicClusterConfig.java @@ -34,7 +34,6 @@ import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddReplicatedMapConfigCodec; import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddRingbufferConfigCodec; import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddScheduledExecutorConfigCodec; -import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddSemaphoreConfigCodec; import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddSetConfigCodec; import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddTopicConfigCodec; import com.hazelcast.client.impl.protocol.task.dynamicconfig.EvictionConfigHolder; @@ -72,29 +71,27 @@ import com.hazelcast.config.PartitionGroupConfig; import com.hazelcast.config.QueryCacheConfig; import com.hazelcast.config.QueueConfig; -import com.hazelcast.config.SplitBrainProtectionConfig; import com.hazelcast.config.ReliableTopicConfig; import com.hazelcast.config.ReplicatedMapConfig; import com.hazelcast.config.RingbufferConfig; import com.hazelcast.config.RingbufferStoreConfig; import com.hazelcast.config.ScheduledExecutorConfig; import com.hazelcast.config.SecurityConfig; -import com.hazelcast.config.SemaphoreConfig; import com.hazelcast.config.SerializationConfig; import com.hazelcast.config.ServicesConfig; import com.hazelcast.config.SetConfig; +import com.hazelcast.config.SplitBrainProtectionConfig; import com.hazelcast.config.TopicConfig; import com.hazelcast.config.UserCodeDeploymentConfig; import com.hazelcast.config.WanReplicationConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.core.ManagedContext; -import com.hazelcast.nio.serialization.Data; import com.hazelcast.internal.serialization.SerializationService; +import com.hazelcast.nio.serialization.Data; import java.io.File; import java.net.URL; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Properties; @@ -335,15 +332,6 @@ public Config addCardinalityEstimatorConfig(CardinalityEstimatorConfig cardinali return this; } - @Override - public Config addSemaphoreConfig(SemaphoreConfig semaphoreConfig) { - ClientMessage request = DynamicConfigAddSemaphoreConfigCodec.encodeRequest( - semaphoreConfig.getName(), semaphoreConfig.getInitialPermits(), semaphoreConfig.getBackupCount(), - semaphoreConfig.getAsyncBackupCount(), semaphoreConfig.getSplitBrainProtectionName()); - invoke(request); - return this; - } - @Override public Config addPNCounterConfig(PNCounterConfig pnCounterConfig) { ClientMessage request = DynamicConfigAddPNCounterConfigCodec.encodeRequest( @@ -791,31 +779,6 @@ public Config setCardinalityEstimatorConfigs( throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE); } - @Override - public SemaphoreConfig findSemaphoreConfig(String name) { - throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE); - } - - @Override - public SemaphoreConfig getSemaphoreConfig(String name) { - throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE); - } - - @Override - public Collection getSemaphoreConfigs() { - throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE); - } - - @Override - public Map getSemaphoreConfigsAsMap() { - throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE); - } - - @Override - public Config setSemaphoreConfigs(Map semaphoreConfigs) { - throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE); - } - @Override public AtomicReferenceConfig findAtomicReferenceConfig(String name) { throw new UnsupportedOperationException(UNSUPPORTED_ERROR_MESSAGE); diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientInstanceImpl.java b/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientInstanceImpl.java index a7f8297c2df56..cc5214d552d6f 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientInstanceImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientInstanceImpl.java @@ -19,12 +19,17 @@ import com.hazelcast.cache.impl.JCacheDetector; import com.hazelcast.cardinality.CardinalityEstimator; import com.hazelcast.cardinality.impl.CardinalityEstimatorService; +import com.hazelcast.client.Client; import com.hazelcast.client.ClientExtension; +import com.hazelcast.client.ClientService; import com.hazelcast.client.HazelcastClient; import com.hazelcast.client.LoadBalancer; import com.hazelcast.client.config.ClientConfig; import com.hazelcast.client.config.ClientFailoverConfig; import com.hazelcast.client.config.ClientNetworkConfig; +import com.hazelcast.client.cp.internal.CPSubsystemImpl; +import com.hazelcast.client.cp.internal.session.ClientProxySessionManager; +import com.hazelcast.client.impl.client.DistributedObjectInfo; import com.hazelcast.client.impl.connection.AddressProvider; import com.hazelcast.client.impl.connection.ClientConnectionManager; import com.hazelcast.client.impl.connection.ClientConnectionStrategy; @@ -32,15 +37,11 @@ import com.hazelcast.client.impl.connection.nio.ClusterConnectorService; import com.hazelcast.client.impl.connection.nio.ClusterConnectorServiceImpl; import com.hazelcast.client.impl.connection.nio.DefaultClientConnectionStrategy; -import com.hazelcast.client.cp.internal.CPSubsystemImpl; -import com.hazelcast.client.cp.internal.session.ClientProxySessionManager; -import com.hazelcast.client.impl.client.DistributedObjectInfo; import com.hazelcast.client.impl.protocol.ClientMessage; import com.hazelcast.client.impl.protocol.codec.ClientGetDistributedObjectsCodec; -import com.hazelcast.client.impl.querycache.ClientQueryCacheContext; -import com.hazelcast.client.impl.statistics.Statistics; import com.hazelcast.client.impl.proxy.ClientClusterProxy; import com.hazelcast.client.impl.proxy.PartitionServiceProxy; +import com.hazelcast.client.impl.querycache.ClientQueryCacheContext; import com.hazelcast.client.impl.spi.ClientClusterService; import com.hazelcast.client.impl.spi.ClientContext; import com.hazelcast.client.impl.spi.ClientExecutionService; @@ -61,7 +62,12 @@ import com.hazelcast.client.impl.spi.impl.listener.AbstractClientListenerService; import com.hazelcast.client.impl.spi.impl.listener.NonSmartClientListenerService; import com.hazelcast.client.impl.spi.impl.listener.SmartClientListenerService; +import com.hazelcast.client.impl.statistics.Statistics; import com.hazelcast.client.util.RoundRobinLB; +import com.hazelcast.cluster.Cluster; +import com.hazelcast.collection.IList; +import com.hazelcast.collection.IQueue; +import com.hazelcast.collection.ISet; import com.hazelcast.collection.impl.list.ListService; import com.hazelcast.collection.impl.queue.QueueService; import com.hazelcast.collection.impl.set.SetService; @@ -69,31 +75,18 @@ import com.hazelcast.cp.internal.datastructures.unsafe.atomicreference.AtomicReferenceService; import com.hazelcast.cp.internal.datastructures.unsafe.idgen.IdGeneratorService; import com.hazelcast.cp.internal.datastructures.unsafe.lock.LockServiceImpl; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; import com.hazelcast.config.Config; import com.hazelcast.config.GroupConfig; -import com.hazelcast.client.Client; -import com.hazelcast.client.ClientService; -import com.hazelcast.cluster.Cluster; import com.hazelcast.core.DistributedObject; import com.hazelcast.core.DistributedObjectListener; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.cp.IAtomicLong; import com.hazelcast.cp.IAtomicReference; import com.hazelcast.core.IExecutorService; -import com.hazelcast.collection.IList; -import com.hazelcast.cp.lock.ILock; -import com.hazelcast.map.IMap; -import com.hazelcast.collection.IQueue; -import com.hazelcast.cp.ISemaphore; -import com.hazelcast.topic.ITopic; -import com.hazelcast.collection.ISet; import com.hazelcast.core.IdGenerator; import com.hazelcast.core.LifecycleService; -import com.hazelcast.multimap.MultiMap; -import com.hazelcast.partition.PartitionService; -import com.hazelcast.replicatedmap.ReplicatedMap; import com.hazelcast.cp.CPSubsystem; +import com.hazelcast.cp.lock.ILock; import com.hazelcast.crdt.pncounter.PNCounter; import com.hazelcast.crdt.pncounter.PNCounterService; import com.hazelcast.durableexecutor.DurableExecutorService; @@ -123,11 +116,14 @@ import com.hazelcast.internal.util.ConcurrencyDetection; import com.hazelcast.logging.ILogger; import com.hazelcast.logging.LoggingService; +import com.hazelcast.map.IMap; import com.hazelcast.map.impl.MapService; +import com.hazelcast.multimap.MultiMap; import com.hazelcast.multimap.impl.MultiMapService; import com.hazelcast.nio.ClassLoaderUtil; import com.hazelcast.nio.Connection; -import com.hazelcast.splitbrainprotection.SplitBrainProtectionService; +import com.hazelcast.partition.PartitionService; +import com.hazelcast.replicatedmap.ReplicatedMap; import com.hazelcast.replicatedmap.impl.ReplicatedMapService; import com.hazelcast.ringbuffer.Ringbuffer; import com.hazelcast.ringbuffer.impl.RingbufferService; @@ -136,6 +132,8 @@ import com.hazelcast.spi.impl.SerializationServiceSupport; import com.hazelcast.spi.properties.GroupProperty; import com.hazelcast.spi.properties.HazelcastProperties; +import com.hazelcast.splitbrainprotection.SplitBrainProtectionService; +import com.hazelcast.topic.ITopic; import com.hazelcast.topic.impl.TopicService; import com.hazelcast.topic.impl.reliable.ReliableTopicService; import com.hazelcast.transaction.HazelcastXAResource; @@ -635,12 +633,6 @@ public IAtomicReference getAtomicReference(String name) { return getDistributedObject(AtomicReferenceService.SERVICE_NAME, name); } - @Override - public ISemaphore getSemaphore(String name) { - checkNotNull(name, "Retrieving a semaphore instance with a null name is not allowed!"); - return getDistributedObject(SemaphoreService.SERVICE_NAME, name); - } - @Override public IScheduledExecutorService getScheduledExecutorService(String name) { checkNotNull(name, "Retrieving a scheduled executor instance with a null name is not allowed!"); diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientProxy.java b/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientProxy.java index 7b82cc1f0cd34..420dc57b6055a 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientProxy.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientProxy.java @@ -36,7 +36,6 @@ import com.hazelcast.cp.CPSubsystem; import com.hazelcast.cp.IAtomicLong; import com.hazelcast.cp.IAtomicReference; -import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.lock.ILock; import com.hazelcast.crdt.pncounter.PNCounter; import com.hazelcast.durableexecutor.DurableExecutorService; @@ -201,11 +200,6 @@ public IAtomicReference getAtomicReference(String name) { return getClient().getAtomicReference(name); } - @Override - public ISemaphore getSemaphore(String name) { - return getClient().getSemaphore(name); - } - @Override public CardinalityEstimator getCardinalityEstimator(String name) { return getClient().getCardinalityEstimator(name); diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/DefaultMessageTaskFactoryProvider.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/DefaultMessageTaskFactoryProvider.java index a0bb8a50b16ab..bf2c9b434660e 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/DefaultMessageTaskFactoryProvider.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/DefaultMessageTaskFactoryProvider.java @@ -21,6 +21,13 @@ import com.hazelcast.client.impl.protocol.codec.CountDownLatchGetCountCodec; import com.hazelcast.client.impl.protocol.codec.CountDownLatchGetRoundCodec; import com.hazelcast.client.impl.protocol.codec.CountDownLatchTrySetCountCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreAcquireCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreAvailablePermitsCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreChangeCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreDrainCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreGetSemaphoreTypeCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreInitCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreReleaseCodec; import com.hazelcast.client.impl.protocol.task.AddPartitionListenerMessageTask; import com.hazelcast.client.impl.protocol.task.CreateProxiesMessageTask; import com.hazelcast.client.impl.protocol.task.DeployClassesMessageTask; @@ -48,7 +55,6 @@ import com.hazelcast.client.impl.protocol.task.dynamicconfig.AddReplicatedMapConfigMessageTask; import com.hazelcast.client.impl.protocol.task.dynamicconfig.AddRingbufferConfigMessageTask; import com.hazelcast.client.impl.protocol.task.dynamicconfig.AddScheduledExecutorConfigMessageTask; -import com.hazelcast.client.impl.protocol.task.dynamicconfig.AddSemaphoreConfigMessageTask; import com.hazelcast.client.impl.protocol.task.dynamicconfig.AddSetConfigMessageTask; import com.hazelcast.client.impl.protocol.task.dynamicconfig.AddTopicConfigMessageTask; import com.hazelcast.client.impl.protocol.task.executorservice.durable.DurableExecutorDisposeResultMessageTask; @@ -637,48 +643,6 @@ public MessageTask create(ClientMessage clientMessage, Connection connection) { } }); //endregion -//region ---------- REGISTRATION FOR com.hazelcast.client.impl.protocol.task.semaphore - factories.put(com.hazelcast.client.impl.protocol.codec.SemaphoreDrainPermitsCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new com.hazelcast.client.impl.protocol.task.semaphore.SemaphoreDrainPermitsMessageTask(clientMessage, node, connection); - } - }); - factories.put(com.hazelcast.client.impl.protocol.codec.SemaphoreAvailablePermitsCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new com.hazelcast.client.impl.protocol.task.semaphore.SemaphoreAvailablePermitsMessageTasks(clientMessage, node, connection); - } - }); - factories.put(com.hazelcast.client.impl.protocol.codec.SemaphoreInitCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new com.hazelcast.client.impl.protocol.task.semaphore.SemaphoreInitMessageTask(clientMessage, node, connection); - } - }); - factories.put(com.hazelcast.client.impl.protocol.codec.SemaphoreAcquireCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new com.hazelcast.client.impl.protocol.task.semaphore.SemaphoreAcquireMessageTask(clientMessage, node, connection); - } - }); - factories.put(com.hazelcast.client.impl.protocol.codec.SemaphoreReducePermitsCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new com.hazelcast.client.impl.protocol.task.semaphore.SemaphoreReducePermitsMessageTask(clientMessage, node, connection); - } - }); - factories.put(com.hazelcast.client.impl.protocol.codec.SemaphoreIncreasePermitsCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new com.hazelcast.client.impl.protocol.task.semaphore.SemaphoreIncreasePermitsMessageTask(clientMessage, node, connection); - } - }); - factories.put(com.hazelcast.client.impl.protocol.codec.SemaphoreTryAcquireCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new com.hazelcast.client.impl.protocol.task.semaphore.SemaphoreTryAcquireMessageTask(clientMessage, node, connection); - } - }); - factories.put(com.hazelcast.client.impl.protocol.codec.SemaphoreReleaseCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new com.hazelcast.client.impl.protocol.task.semaphore.SemaphoreReleaseMessageTask(clientMessage, node, connection); - } - }); -//endregion //region ---------- REGISTRATION FOR com.hazelcast.client.impl.protocol.task.transactionallist factories.put(com.hazelcast.client.impl.protocol.codec.TransactionalListSizeCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { public MessageTask create(ClientMessage clientMessage, Connection connection) { @@ -2048,11 +2012,6 @@ public MessageTask create(ClientMessage clientMessage, Connection connection) { return new AddSetConfigMessageTask(clientMessage, node, connection); } }); - factories.put(com.hazelcast.client.impl.protocol.codec.DynamicConfigAddSemaphoreConfigCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { - public MessageTask create(ClientMessage clientMessage, Connection connection) { - return new AddSemaphoreConfigMessageTask(clientMessage, node, connection); - } - }); factories.put(com.hazelcast.client.impl.protocol.codec.DynamicConfigAddTopicConfigCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { public MessageTask create(ClientMessage clientMessage, Connection connection) { return new AddTopicConfigMessageTask(clientMessage, node, connection); @@ -2283,43 +2242,43 @@ public MessageTask create(ClientMessage clientMessage, Connection connection) { } }); - factories.put(com.hazelcast.client.impl.protocol.codec.CPSemaphoreAcquireCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { + factories.put(SemaphoreAcquireCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { @Override public MessageTask create(ClientMessage clientMessage, Connection connection) { return new AcquirePermitsMessageTask(clientMessage, node, connection); } }); - factories.put(com.hazelcast.client.impl.protocol.codec.CPSemaphoreAvailablePermitsCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { + factories.put(SemaphoreAvailablePermitsCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { @Override public MessageTask create(ClientMessage clientMessage, Connection connection) { return new AvailablePermitsMessageTask(clientMessage, node, connection); } }); - factories.put(com.hazelcast.client.impl.protocol.codec.CPSemaphoreChangeCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { + factories.put(SemaphoreChangeCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { @Override public MessageTask create(ClientMessage clientMessage, Connection connection) { return new ChangePermitsMessageTask(clientMessage, node, connection); } }); - factories.put(com.hazelcast.client.impl.protocol.codec.CPSemaphoreDrainCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { + factories.put(SemaphoreDrainCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { @Override public MessageTask create(ClientMessage clientMessage, Connection connection) { return new DrainPermitsMessageTask(clientMessage, node, connection); } }); - factories.put(com.hazelcast.client.impl.protocol.codec.CPSemaphoreGetSemaphoreTypeCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { + factories.put(SemaphoreGetSemaphoreTypeCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { @Override public MessageTask create(ClientMessage clientMessage, Connection connection) { return new GetSemaphoreTypeMessageTask(clientMessage, node, connection); } }); - factories.put(com.hazelcast.client.impl.protocol.codec.CPSemaphoreInitCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { + factories.put(SemaphoreInitCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { @Override public MessageTask create(ClientMessage clientMessage, Connection connection) { return new InitSemaphoreMessageTask(clientMessage, node, connection); } }); - factories.put(com.hazelcast.client.impl.protocol.codec.CPSemaphoreReleaseCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { + factories.put(SemaphoreReleaseCodec.REQUEST_MESSAGE_TYPE, new MessageTaskFactory() { @Override public MessageTask create(ClientMessage clientMessage, Connection connection) { return new ReleasePermitsMessageTask(clientMessage, node, connection); diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreAcquireCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreAcquireCodec.java deleted file mode 100644 index 69d097d980daf..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreAcquireCodec.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Acquires the requested amount of permits if available, reducing - * the number of available permits. If no enough permits are available, - * then the current thread becomes disabled for thread scheduling purposes - * and lies dormant until other threads release enough permits. - */ -@Generated({"f71bba75d38c2b8843ba0815a78e8bb4"}) -public final class CPSemaphoreAcquireCodec { - //hex: 0x270200 - public static final int REQUEST_MESSAGE_TYPE = 2556416; - //hex: 0x270201 - public static final int RESPONSE_MESSAGE_TYPE = 2556417; - private static final int REQUEST_SESSION_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_THREAD_ID_FIELD_OFFSET = REQUEST_SESSION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int REQUEST_INVOCATION_UID_FIELD_OFFSET = REQUEST_THREAD_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int REQUEST_PERMITS_FIELD_OFFSET = REQUEST_INVOCATION_UID_FIELD_OFFSET + UUID_SIZE_IN_BYTES; - private static final int REQUEST_TIMEOUT_MS_FIELD_OFFSET = REQUEST_PERMITS_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_TIMEOUT_MS_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + BOOLEAN_SIZE_IN_BYTES; - - private CPSemaphoreAcquireCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * CP group id of this ISemaphore instance - */ - public com.hazelcast.cp.internal.RaftGroupId groupId; - - /** - * Name of this ISemaphore instance - */ - public java.lang.String name; - - /** - * Session ID of the caller - */ - public long sessionId; - - /** - * ID of the caller thread - */ - public long threadId; - - /** - * UID of this invocation - */ - public java.util.UUID invocationUid; - - /** - * number of permits to acquire - */ - public int permits; - - /** - * Duration to wait for permit acquire - */ - public long timeoutMs; - } - - public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId groupId, java.lang.String name, long sessionId, long threadId, java.util.UUID invocationUid, int permits, long timeoutMs) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(true); - clientMessage.setAcquiresResource(false); - clientMessage.setOperationName("CPSemaphore.Acquire"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - encodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET, sessionId); - encodeLong(initialFrame.content, REQUEST_THREAD_ID_FIELD_OFFSET, threadId); - encodeUUID(initialFrame.content, REQUEST_INVOCATION_UID_FIELD_OFFSET, invocationUid); - encodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET, permits); - encodeLong(initialFrame.content, REQUEST_TIMEOUT_MS_FIELD_OFFSET, timeoutMs); - clientMessage.add(initialFrame); - RaftGroupIdCodec.encode(clientMessage, groupId); - StringCodec.encode(clientMessage, name); - return clientMessage; - } - - public static CPSemaphoreAcquireCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - request.sessionId = decodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET); - request.threadId = decodeLong(initialFrame.content, REQUEST_THREAD_ID_FIELD_OFFSET); - request.invocationUid = decodeUUID(initialFrame.content, REQUEST_INVOCATION_UID_FIELD_OFFSET); - request.permits = decodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET); - request.timeoutMs = decodeLong(initialFrame.content, REQUEST_TIMEOUT_MS_FIELD_OFFSET); - request.groupId = RaftGroupIdCodec.decode(iterator); - request.name = StringCodec.decode(iterator); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - - /** - * true if requested permits are acquired, - * false otherwise - */ - public boolean response; - } - - public static ClientMessage encodeResponse(boolean response) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - encodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET, response); - return clientMessage; - } - - public static CPSemaphoreAcquireCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - response.response = decodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreAvailablePermitsCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreAvailablePermitsCodec.java deleted file mode 100644 index 2c2ede36f1fd6..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreAvailablePermitsCodec.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Returns the number of available permits. - */ -@Generated({"55284ab3e0b2db6cf1a444d990397d91"}) -public final class CPSemaphoreAvailablePermitsCodec { - //hex: 0x270600 - public static final int REQUEST_MESSAGE_TYPE = 2557440; - //hex: 0x270601 - public static final int RESPONSE_MESSAGE_TYPE = 2557441; - private static final int REQUEST_INITIAL_FRAME_SIZE = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + INT_SIZE_IN_BYTES; - - private CPSemaphoreAvailablePermitsCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * CP group id of this ISemaphore instance - */ - public com.hazelcast.cp.internal.RaftGroupId groupId; - - /** - * Name of this ISemaphore instance - */ - public java.lang.String name; - } - - public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId groupId, java.lang.String name) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(true); - clientMessage.setAcquiresResource(false); - clientMessage.setOperationName("CPSemaphore.AvailablePermits"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - clientMessage.add(initialFrame); - RaftGroupIdCodec.encode(clientMessage, groupId); - StringCodec.encode(clientMessage, name); - return clientMessage; - } - - public static CPSemaphoreAvailablePermitsCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - //empty initial frame - iterator.next(); - request.groupId = RaftGroupIdCodec.decode(iterator); - request.name = StringCodec.decode(iterator); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - - /** - * number of available permits - */ - public int response; - } - - public static ClientMessage encodeResponse(int response) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - encodeInt(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET, response); - return clientMessage; - } - - public static CPSemaphoreAvailablePermitsCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - response.response = decodeInt(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreInitCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreInitCodec.java deleted file mode 100644 index b1987f7969dae..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreInitCodec.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Initializes the ISemaphore instance with the given permit number, if not - * initialized before. - */ -@Generated({"50bd094fd01e4b41be939dd7ae028752"}) -public final class CPSemaphoreInitCodec { - //hex: 0x270100 - public static final int REQUEST_MESSAGE_TYPE = 2556160; - //hex: 0x270101 - public static final int RESPONSE_MESSAGE_TYPE = 2556161; - private static final int REQUEST_PERMITS_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_PERMITS_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + BOOLEAN_SIZE_IN_BYTES; - - private CPSemaphoreInitCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * CP group id of this ISemaphore instance - */ - public com.hazelcast.cp.internal.RaftGroupId groupId; - - /** - * Name of this ISemaphore instance - */ - public java.lang.String name; - - /** - * Number of permits to initialize this ISemaphore - */ - public int permits; - } - - public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId groupId, java.lang.String name, int permits) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(true); - clientMessage.setAcquiresResource(false); - clientMessage.setOperationName("CPSemaphore.Init"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - encodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET, permits); - clientMessage.add(initialFrame); - RaftGroupIdCodec.encode(clientMessage, groupId); - StringCodec.encode(clientMessage, name); - return clientMessage; - } - - public static CPSemaphoreInitCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - request.permits = decodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET); - request.groupId = RaftGroupIdCodec.decode(iterator); - request.name = StringCodec.decode(iterator); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - - /** - * true if the ISemaphore is initialized with this call - */ - public boolean response; - } - - public static ClientMessage encodeResponse(boolean response) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - encodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET, response); - return clientMessage; - } - - public static CPSemaphoreInitCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - response.response = decodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreReleaseCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreReleaseCodec.java deleted file mode 100644 index 588352347dbf1..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreReleaseCodec.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Releases the given number of permits and increases the number of - * available permits by that amount. - */ -@Generated({"e8434f88e1f0ec74e66c4a036791379c"}) -public final class CPSemaphoreReleaseCodec { - //hex: 0x270300 - public static final int REQUEST_MESSAGE_TYPE = 2556672; - //hex: 0x270301 - public static final int RESPONSE_MESSAGE_TYPE = 2556673; - private static final int REQUEST_SESSION_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_THREAD_ID_FIELD_OFFSET = REQUEST_SESSION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int REQUEST_INVOCATION_UID_FIELD_OFFSET = REQUEST_THREAD_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int REQUEST_PERMITS_FIELD_OFFSET = REQUEST_INVOCATION_UID_FIELD_OFFSET + UUID_SIZE_IN_BYTES; - private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_PERMITS_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + BOOLEAN_SIZE_IN_BYTES; - - private CPSemaphoreReleaseCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * CP group id of this ISemaphore instance - */ - public com.hazelcast.cp.internal.RaftGroupId groupId; - - /** - * Name of this ISemaphore instance - */ - public java.lang.String name; - - /** - * Session ID of the caller - */ - public long sessionId; - - /** - * ID of the caller thread - */ - public long threadId; - - /** - * UID of this invocation - */ - public java.util.UUID invocationUid; - - /** - * number of permits to release - */ - public int permits; - } - - public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId groupId, java.lang.String name, long sessionId, long threadId, java.util.UUID invocationUid, int permits) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(true); - clientMessage.setAcquiresResource(false); - clientMessage.setOperationName("CPSemaphore.Release"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - encodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET, sessionId); - encodeLong(initialFrame.content, REQUEST_THREAD_ID_FIELD_OFFSET, threadId); - encodeUUID(initialFrame.content, REQUEST_INVOCATION_UID_FIELD_OFFSET, invocationUid); - encodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET, permits); - clientMessage.add(initialFrame); - RaftGroupIdCodec.encode(clientMessage, groupId); - StringCodec.encode(clientMessage, name); - return clientMessage; - } - - public static CPSemaphoreReleaseCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - request.sessionId = decodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET); - request.threadId = decodeLong(initialFrame.content, REQUEST_THREAD_ID_FIELD_OFFSET); - request.invocationUid = decodeUUID(initialFrame.content, REQUEST_INVOCATION_UID_FIELD_OFFSET); - request.permits = decodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET); - request.groupId = RaftGroupIdCodec.decode(iterator); - request.name = StringCodec.decode(iterator); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - - /** - * true - */ - public boolean response; - } - - public static ClientMessage encodeResponse(boolean response) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - encodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET, response); - return clientMessage; - } - - public static CPSemaphoreReleaseCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - response.response = decodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/ClientCreateProxyCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/ClientCreateProxyCodec.java index a04c5d9e3f8c4..f6d6b867f896c 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/ClientCreateProxyCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/ClientCreateProxyCodec.java @@ -35,7 +35,7 @@ /** * TODO DOC */ -@Generated({"5af69dac389a9ccaa09ef677a4c4a398"}) +@Generated({"06748e4f1be4be6064934662529a2dc6"}) public final class ClientCreateProxyCodec { //hex: 0x000500 public static final int REQUEST_MESSAGE_TYPE = 1280; @@ -63,7 +63,6 @@ public static class RequestParameters { * "hz:impl:atomicLongService" * "hz:impl:atomicReferenceService" * "hz:impl:idGeneratorService" - * "hz:impl:semaphoreService" * "hz:impl:executorService" * "hz:impl:mapService" * "hz:impl:multiMapService" diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/ClientDestroyProxyCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/ClientDestroyProxyCodec.java index 7219e771b3dda..478342ef97ad0 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/ClientDestroyProxyCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/ClientDestroyProxyCodec.java @@ -35,7 +35,7 @@ /** * TODO DOC */ -@Generated({"75aef24594239e8260c00fed9d58e867"}) +@Generated({"17775574936774d9cf640e1e43572498"}) public final class ClientDestroyProxyCodec { //hex: 0x000600 public static final int REQUEST_MESSAGE_TYPE = 1536; @@ -63,7 +63,6 @@ public static class RequestParameters { * "hz:impl:atomicLongService" * "hz:impl:atomicReferenceService" * "hz:impl:idGeneratorService" - * "hz:impl:semaphoreService" * "hz:impl:executorService" * "hz:impl:mapService" * "hz:impl:multiMapService" diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/DynamicConfigAddSemaphoreConfigCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/DynamicConfigAddSemaphoreConfigCodec.java deleted file mode 100644 index 60ee9ac368457..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/DynamicConfigAddSemaphoreConfigCodec.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Adds a new semaphore configuration to a running cluster. - * If a semaphore configuration with the given {@code name} already exists, then - * the new configuration is ignored and the existing one is preserved. - */ -@Generated({"d8e4bd05bb7803e0aa183818ee3360ad"}) -public final class DynamicConfigAddSemaphoreConfigCodec { - //hex: 0x1E0C00 - public static final int REQUEST_MESSAGE_TYPE = 1969152; - //hex: 0x1E0C01 - public static final int RESPONSE_MESSAGE_TYPE = 1969153; - private static final int REQUEST_INITIAL_PERMITS_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_BACKUP_COUNT_FIELD_OFFSET = REQUEST_INITIAL_PERMITS_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_ASYNC_BACKUP_COUNT_FIELD_OFFSET = REQUEST_BACKUP_COUNT_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_ASYNC_BACKUP_COUNT_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - - private DynamicConfigAddSemaphoreConfigCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * semaphore configuration name - */ - public java.lang.String name; - - /** - * thread count to which the concurrent access is limited - */ - public int initialPermits; - - /** - * number of synchronous backups - */ - public int backupCount; - - /** - * number of asynchronous backups - */ - public int asyncBackupCount; - - /** - * name of an existing configured split brain protection to be used to determine the minimum number of members - * required in the cluster for the lock to remain functional. When {@code null}, split brain protection does not - * apply to this lock configuration's operations. - */ - public java.lang.String splitBrainProtectionName; - } - - public static ClientMessage encodeRequest(java.lang.String name, int initialPermits, int backupCount, int asyncBackupCount, java.lang.String splitBrainProtectionName) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(false); - clientMessage.setAcquiresResource(false); - clientMessage.setOperationName("DynamicConfig.AddSemaphoreConfig"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - encodeInt(initialFrame.content, REQUEST_INITIAL_PERMITS_FIELD_OFFSET, initialPermits); - encodeInt(initialFrame.content, REQUEST_BACKUP_COUNT_FIELD_OFFSET, backupCount); - encodeInt(initialFrame.content, REQUEST_ASYNC_BACKUP_COUNT_FIELD_OFFSET, asyncBackupCount); - clientMessage.add(initialFrame); - StringCodec.encode(clientMessage, name); - CodecUtil.encodeNullable(clientMessage, splitBrainProtectionName, StringCodec::encode); - return clientMessage; - } - - public static DynamicConfigAddSemaphoreConfigCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - request.initialPermits = decodeInt(initialFrame.content, REQUEST_INITIAL_PERMITS_FIELD_OFFSET); - request.backupCount = decodeInt(initialFrame.content, REQUEST_BACKUP_COUNT_FIELD_OFFSET); - request.asyncBackupCount = decodeInt(initialFrame.content, REQUEST_ASYNC_BACKUP_COUNT_FIELD_OFFSET); - request.name = StringCodec.decode(iterator); - request.splitBrainProtectionName = CodecUtil.decodeNullable(iterator, StringCodec::decode); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - } - - public static ClientMessage encodeResponse() { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - return clientMessage; - } - - public static DynamicConfigAddSemaphoreConfigCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - //empty initial frame - iterator.next(); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreAcquireCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreAcquireCodec.java index ad6708cac76b6..62c7c0e0c4d8e 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreAcquireCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreAcquireCodec.java @@ -33,23 +33,25 @@ */ /** - * Acquires the given number of permits if they are available, and returns immediately, reducing the number of - * available permits by the given amount. If insufficient permits are available then the current thread becomes - * disabled for thread scheduling purposes and lies dormant until one of three things happens: some other thread - * invokes one of the methods for this semaphore, the current thread is next to be assigned permits and the number - * of available permits satisfies this request, this ISemaphore instance is destroyed, or some other thread - * the current thread. If the current thread has its interrupted status set on entry to this method, or is while - * waiting for a permit, then is thrown and the current thread's interrupted status is cleared. + * Acquires the requested amount of permits if available, reducing + * the number of available permits. If no enough permits are available, + * then the current thread becomes disabled for thread scheduling purposes + * and lies dormant until other threads release enough permits. */ -@Generated({"ba8b0ec0a184e2faa693ccefbec6ca01"}) +@Generated({"4341ff0b77e0a57214d979328530dea7"}) public final class SemaphoreAcquireCodec { //hex: 0x0D0200 public static final int REQUEST_MESSAGE_TYPE = 852480; //hex: 0x0D0201 public static final int RESPONSE_MESSAGE_TYPE = 852481; - private static final int REQUEST_PERMITS_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_PERMITS_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int REQUEST_SESSION_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; + private static final int REQUEST_THREAD_ID_FIELD_OFFSET = REQUEST_SESSION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int REQUEST_INVOCATION_UID_FIELD_OFFSET = REQUEST_THREAD_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int REQUEST_PERMITS_FIELD_OFFSET = REQUEST_INVOCATION_UID_FIELD_OFFSET + UUID_SIZE_IN_BYTES; + private static final int REQUEST_TIMEOUT_MS_FIELD_OFFSET = REQUEST_PERMITS_FIELD_OFFSET + INT_SIZE_IN_BYTES; + private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_TIMEOUT_MS_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + BOOLEAN_SIZE_IN_BYTES; private SemaphoreAcquireCodec() { } @@ -58,25 +60,55 @@ private SemaphoreAcquireCodec() { public static class RequestParameters { /** - * Name of the Semaphore + * CP group id of this ISemaphore instance + */ + public com.hazelcast.cp.internal.RaftGroupId groupId; + + /** + * Name of this ISemaphore instance */ public java.lang.String name; /** - * The given permit count + * Session ID of the caller + */ + public long sessionId; + + /** + * ID of the caller thread + */ + public long threadId; + + /** + * UID of this invocation + */ + public java.util.UUID invocationUid; + + /** + * number of permits to acquire */ public int permits; + + /** + * Duration to wait for permit acquire + */ + public long timeoutMs; } - public static ClientMessage encodeRequest(java.lang.String name, int permits) { + public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId groupId, java.lang.String name, long sessionId, long threadId, java.util.UUID invocationUid, int permits, long timeoutMs) { ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(false); - clientMessage.setAcquiresResource(true); + clientMessage.setRetryable(true); + clientMessage.setAcquiresResource(false); clientMessage.setOperationName("Semaphore.Acquire"); ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); + encodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET, sessionId); + encodeLong(initialFrame.content, REQUEST_THREAD_ID_FIELD_OFFSET, threadId); + encodeUUID(initialFrame.content, REQUEST_INVOCATION_UID_FIELD_OFFSET, invocationUid); encodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET, permits); + encodeLong(initialFrame.content, REQUEST_TIMEOUT_MS_FIELD_OFFSET, timeoutMs); clientMessage.add(initialFrame); + RaftGroupIdCodec.encode(clientMessage, groupId); StringCodec.encode(clientMessage, name); return clientMessage; } @@ -85,29 +117,41 @@ public static SemaphoreAcquireCodec.RequestParameters decodeRequest(ClientMessag ListIterator iterator = clientMessage.listIterator(); RequestParameters request = new RequestParameters(); ClientMessage.Frame initialFrame = iterator.next(); + request.sessionId = decodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET); + request.threadId = decodeLong(initialFrame.content, REQUEST_THREAD_ID_FIELD_OFFSET); + request.invocationUid = decodeUUID(initialFrame.content, REQUEST_INVOCATION_UID_FIELD_OFFSET); request.permits = decodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET); + request.timeoutMs = decodeLong(initialFrame.content, REQUEST_TIMEOUT_MS_FIELD_OFFSET); + request.groupId = RaftGroupIdCodec.decode(iterator); request.name = StringCodec.decode(iterator); return request; } @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) public static class ResponseParameters { + + /** + * true if requested permits are acquired, + * false otherwise + */ + public boolean response; } - public static ClientMessage encodeResponse() { + public static ClientMessage encodeResponse(boolean response) { ClientMessage clientMessage = ClientMessage.createForEncode(); ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); clientMessage.add(initialFrame); + encodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET, response); return clientMessage; } public static SemaphoreAcquireCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { ListIterator iterator = clientMessage.listIterator(); ResponseParameters response = new ResponseParameters(); - //empty initial frame - iterator.next(); + ClientMessage.Frame initialFrame = iterator.next(); + response.response = decodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET); return response; } diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreAvailablePermitsCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreAvailablePermitsCodec.java index dd1d08e88da3e..92e7ea8f50b5f 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreAvailablePermitsCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreAvailablePermitsCodec.java @@ -33,15 +33,14 @@ */ /** - * Returns the current number of permits currently available in this semaphore. This method is typically used for - * debugging and testing purposes. + * Returns the number of available permits. */ -@Generated({"d3bff9f6caa906186ec45c6d2ccd461e"}) +@Generated({"4249b2901e928e3006e3f3275f4daf80"}) public final class SemaphoreAvailablePermitsCodec { - //hex: 0x0D0300 - public static final int REQUEST_MESSAGE_TYPE = 852736; - //hex: 0x0D0301 - public static final int RESPONSE_MESSAGE_TYPE = 852737; + //hex: 0x0D0600 + public static final int REQUEST_MESSAGE_TYPE = 853504; + //hex: 0x0D0601 + public static final int RESPONSE_MESSAGE_TYPE = 853505; private static final int REQUEST_INITIAL_FRAME_SIZE = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + INT_SIZE_IN_BYTES; @@ -53,12 +52,17 @@ private SemaphoreAvailablePermitsCodec() { public static class RequestParameters { /** - * Name of the Semaphore + * CP group id of this ISemaphore instance + */ + public com.hazelcast.cp.internal.RaftGroupId groupId; + + /** + * Name of this ISemaphore instance */ public java.lang.String name; } - public static ClientMessage encodeRequest(java.lang.String name) { + public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId groupId, java.lang.String name) { ClientMessage clientMessage = ClientMessage.createForEncode(); clientMessage.setRetryable(true); clientMessage.setAcquiresResource(false); @@ -66,6 +70,7 @@ public static ClientMessage encodeRequest(java.lang.String name) { ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); clientMessage.add(initialFrame); + RaftGroupIdCodec.encode(clientMessage, groupId); StringCodec.encode(clientMessage, name); return clientMessage; } @@ -75,6 +80,7 @@ public static SemaphoreAvailablePermitsCodec.RequestParameters decodeRequest(Cli RequestParameters request = new RequestParameters(); //empty initial frame iterator.next(); + request.groupId = RaftGroupIdCodec.decode(iterator); request.name = StringCodec.decode(iterator); return request; } @@ -83,7 +89,7 @@ public static SemaphoreAvailablePermitsCodec.RequestParameters decodeRequest(Cli public static class ResponseParameters { /** - * The number of permits available in this semaphore. + * number of available permits */ public int response; } diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreChangeCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreChangeCodec.java similarity index 91% rename from hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreChangeCodec.java rename to hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreChangeCodec.java index ba8d246e5f5af..4f222132376e3 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreChangeCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreChangeCodec.java @@ -35,12 +35,12 @@ /** * Increases or decreases the number of permits by the given value. */ -@Generated({"77b019a00e0bd114e962ddd0013cdbf2"}) -public final class CPSemaphoreChangeCodec { - //hex: 0x270500 - public static final int REQUEST_MESSAGE_TYPE = 2557184; - //hex: 0x270501 - public static final int RESPONSE_MESSAGE_TYPE = 2557185; +@Generated({"963636359bb83a81bd68c083b9cd3b7f"}) +public final class SemaphoreChangeCodec { + //hex: 0x0D0500 + public static final int REQUEST_MESSAGE_TYPE = 853248; + //hex: 0x0D0501 + public static final int RESPONSE_MESSAGE_TYPE = 853249; private static final int REQUEST_SESSION_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; private static final int REQUEST_THREAD_ID_FIELD_OFFSET = REQUEST_SESSION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; private static final int REQUEST_INVOCATION_UID_FIELD_OFFSET = REQUEST_THREAD_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; @@ -49,7 +49,7 @@ public final class CPSemaphoreChangeCodec { private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + BOOLEAN_SIZE_IN_BYTES; - private CPSemaphoreChangeCodec() { + private SemaphoreChangeCodec() { } @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) @@ -90,7 +90,7 @@ public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId ClientMessage clientMessage = ClientMessage.createForEncode(); clientMessage.setRetryable(true); clientMessage.setAcquiresResource(false); - clientMessage.setOperationName("CPSemaphore.Change"); + clientMessage.setOperationName("Semaphore.Change"); ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); encodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET, sessionId); @@ -103,7 +103,7 @@ public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId return clientMessage; } - public static CPSemaphoreChangeCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { + public static SemaphoreChangeCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { ListIterator iterator = clientMessage.listIterator(); RequestParameters request = new RequestParameters(); ClientMessage.Frame initialFrame = iterator.next(); @@ -135,7 +135,7 @@ public static ClientMessage encodeResponse(boolean response) { return clientMessage; } - public static CPSemaphoreChangeCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { + public static SemaphoreChangeCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { ListIterator iterator = clientMessage.listIterator(); ResponseParameters response = new ResponseParameters(); ClientMessage.Frame initialFrame = iterator.next(); diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreDrainCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreDrainCodec.java similarity index 90% rename from hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreDrainCodec.java rename to hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreDrainCodec.java index 47a1c875ec2ed..a40de5bf3d024 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreDrainCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreDrainCodec.java @@ -35,12 +35,12 @@ /** * Acquires all available permits at once and returns immediately. */ -@Generated({"6c1e56a4498df7fbce4e4b6ebde99629"}) -public final class CPSemaphoreDrainCodec { - //hex: 0x270400 - public static final int REQUEST_MESSAGE_TYPE = 2556928; - //hex: 0x270401 - public static final int RESPONSE_MESSAGE_TYPE = 2556929; +@Generated({"6fd8e5e182f2f589ba0c3afc76f50284"}) +public final class SemaphoreDrainCodec { + //hex: 0x0D0400 + public static final int REQUEST_MESSAGE_TYPE = 852992; + //hex: 0x0D0401 + public static final int RESPONSE_MESSAGE_TYPE = 852993; private static final int REQUEST_SESSION_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; private static final int REQUEST_THREAD_ID_FIELD_OFFSET = REQUEST_SESSION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; private static final int REQUEST_INVOCATION_UID_FIELD_OFFSET = REQUEST_THREAD_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; @@ -48,7 +48,7 @@ public final class CPSemaphoreDrainCodec { private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private CPSemaphoreDrainCodec() { + private SemaphoreDrainCodec() { } @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) @@ -84,7 +84,7 @@ public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId ClientMessage clientMessage = ClientMessage.createForEncode(); clientMessage.setRetryable(true); clientMessage.setAcquiresResource(false); - clientMessage.setOperationName("CPSemaphore.Drain"); + clientMessage.setOperationName("Semaphore.Drain"); ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); encodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET, sessionId); @@ -96,7 +96,7 @@ public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId return clientMessage; } - public static CPSemaphoreDrainCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { + public static SemaphoreDrainCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { ListIterator iterator = clientMessage.listIterator(); RequestParameters request = new RequestParameters(); ClientMessage.Frame initialFrame = iterator.next(); @@ -127,7 +127,7 @@ public static ClientMessage encodeResponse(int response) { return clientMessage; } - public static CPSemaphoreDrainCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { + public static SemaphoreDrainCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { ListIterator iterator = clientMessage.listIterator(); ResponseParameters response = new ResponseParameters(); ClientMessage.Frame initialFrame = iterator.next(); diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreDrainPermitsCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreDrainPermitsCodec.java deleted file mode 100644 index c6fbd85338444..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreDrainPermitsCodec.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Acquires and returns all permits that are immediately available. - */ -@Generated({"ec574d6bf20bb3ca83b1b5084450fe36"}) -public final class SemaphoreDrainPermitsCodec { - //hex: 0x0D0400 - public static final int REQUEST_MESSAGE_TYPE = 852992; - //hex: 0x0D0401 - public static final int RESPONSE_MESSAGE_TYPE = 852993; - private static final int REQUEST_INITIAL_FRAME_SIZE = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + INT_SIZE_IN_BYTES; - - private SemaphoreDrainPermitsCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * Name of the Semaphore - */ - public java.lang.String name; - } - - public static ClientMessage encodeRequest(java.lang.String name) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(false); - clientMessage.setAcquiresResource(true); - clientMessage.setOperationName("Semaphore.DrainPermits"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - clientMessage.add(initialFrame); - StringCodec.encode(clientMessage, name); - return clientMessage; - } - - public static SemaphoreDrainPermitsCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - //empty initial frame - iterator.next(); - request.name = StringCodec.decode(iterator); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - - /** - * The number of permits drained - */ - public int response; - } - - public static ClientMessage encodeResponse(int response) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - encodeInt(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET, response); - return clientMessage; - } - - public static SemaphoreDrainPermitsCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - response.response = decodeInt(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreGetSemaphoreTypeCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreGetSemaphoreTypeCodec.java similarity index 86% rename from hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreGetSemaphoreTypeCodec.java rename to hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreGetSemaphoreTypeCodec.java index cf31eb31a2fe2..ee27343ab4114 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/CPSemaphoreGetSemaphoreTypeCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreGetSemaphoreTypeCodec.java @@ -35,17 +35,17 @@ /** * Returns true if the semaphore is JDK compatible */ -@Generated({"0c8a42abd8d531e63b3a6394fb211ec4"}) -public final class CPSemaphoreGetSemaphoreTypeCodec { - //hex: 0x270700 - public static final int REQUEST_MESSAGE_TYPE = 2557696; - //hex: 0x270701 - public static final int RESPONSE_MESSAGE_TYPE = 2557697; +@Generated({"0fb66cc6d5e27b213cd838d3a91b6886"}) +public final class SemaphoreGetSemaphoreTypeCodec { + //hex: 0x0D0700 + public static final int REQUEST_MESSAGE_TYPE = 853760; + //hex: 0x0D0701 + public static final int RESPONSE_MESSAGE_TYPE = 853761; private static final int REQUEST_INITIAL_FRAME_SIZE = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + BOOLEAN_SIZE_IN_BYTES; - private CPSemaphoreGetSemaphoreTypeCodec() { + private SemaphoreGetSemaphoreTypeCodec() { } @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) @@ -61,7 +61,7 @@ public static ClientMessage encodeRequest(java.lang.String proxyName) { ClientMessage clientMessage = ClientMessage.createForEncode(); clientMessage.setRetryable(true); clientMessage.setAcquiresResource(false); - clientMessage.setOperationName("CPSemaphore.GetSemaphoreType"); + clientMessage.setOperationName("Semaphore.GetSemaphoreType"); ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); clientMessage.add(initialFrame); @@ -69,7 +69,7 @@ public static ClientMessage encodeRequest(java.lang.String proxyName) { return clientMessage; } - public static CPSemaphoreGetSemaphoreTypeCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { + public static SemaphoreGetSemaphoreTypeCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { ListIterator iterator = clientMessage.listIterator(); RequestParameters request = new RequestParameters(); //empty initial frame @@ -97,7 +97,7 @@ public static ClientMessage encodeResponse(boolean response) { return clientMessage; } - public static CPSemaphoreGetSemaphoreTypeCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { + public static SemaphoreGetSemaphoreTypeCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { ListIterator iterator = clientMessage.listIterator(); ResponseParameters response = new ResponseParameters(); ClientMessage.Frame initialFrame = iterator.next(); diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreIncreasePermitsCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreIncreasePermitsCodec.java deleted file mode 100644 index e44bc50e6d637..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreIncreasePermitsCodec.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Increases the number of available permits by the indicated amount. This method differs from {@code release} - * in that it does not effect the amount of permits this caller has attached. - */ -@Generated({"47d60651928c41d92b51f5cf1845b32f"}) -public final class SemaphoreIncreasePermitsCodec { - //hex: 0x0D0800 - public static final int REQUEST_MESSAGE_TYPE = 854016; - //hex: 0x0D0801 - public static final int RESPONSE_MESSAGE_TYPE = 854017; - private static final int REQUEST_INCREASE_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_INCREASE_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - - private SemaphoreIncreasePermitsCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * Name of the Semaphore - */ - public java.lang.String name; - - /** - * The number of permits to add - * @throws IllegalArgumentException if {@code increase} is negative - */ - public int increase; - } - - public static ClientMessage encodeRequest(java.lang.String name, int increase) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(false); - clientMessage.setAcquiresResource(true); - clientMessage.setOperationName("Semaphore.IncreasePermits"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - encodeInt(initialFrame.content, REQUEST_INCREASE_FIELD_OFFSET, increase); - clientMessage.add(initialFrame); - StringCodec.encode(clientMessage, name); - return clientMessage; - } - - public static SemaphoreIncreasePermitsCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - request.increase = decodeInt(initialFrame.content, REQUEST_INCREASE_FIELD_OFFSET); - request.name = StringCodec.decode(iterator); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - } - - public static ClientMessage encodeResponse() { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - return clientMessage; - } - - public static SemaphoreIncreasePermitsCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - //empty initial frame - iterator.next(); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreInitCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreInitCodec.java index 48e2230ff7423..839f6192ade42 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreInitCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreInitCodec.java @@ -33,9 +33,10 @@ */ /** - * Try to initialize this ISemaphore instance with the given permit count + * Initializes the ISemaphore instance with the given permit number, if not + * initialized before. */ -@Generated({"3af82024851816c74adad8fac26d1daf"}) +@Generated({"228385eff6d93ad959b3a0ec00bacea3"}) public final class SemaphoreInitCodec { //hex: 0x0D0100 public static final int REQUEST_MESSAGE_TYPE = 852224; @@ -53,25 +54,31 @@ private SemaphoreInitCodec() { public static class RequestParameters { /** - * Name of the Semaphore + * CP group id of this ISemaphore instance + */ + public com.hazelcast.cp.internal.RaftGroupId groupId; + + /** + * Name of this ISemaphore instance */ public java.lang.String name; /** - * The given permit count + * Number of permits to initialize this ISemaphore */ public int permits; } - public static ClientMessage encodeRequest(java.lang.String name, int permits) { + public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId groupId, java.lang.String name, int permits) { ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(false); - clientMessage.setAcquiresResource(true); + clientMessage.setRetryable(true); + clientMessage.setAcquiresResource(false); clientMessage.setOperationName("Semaphore.Init"); ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); encodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET, permits); clientMessage.add(initialFrame); + RaftGroupIdCodec.encode(clientMessage, groupId); StringCodec.encode(clientMessage, name); return clientMessage; } @@ -81,6 +88,7 @@ public static SemaphoreInitCodec.RequestParameters decodeRequest(ClientMessage c RequestParameters request = new RequestParameters(); ClientMessage.Frame initialFrame = iterator.next(); request.permits = decodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET); + request.groupId = RaftGroupIdCodec.decode(iterator); request.name = StringCodec.decode(iterator); return request; } @@ -89,7 +97,7 @@ public static SemaphoreInitCodec.RequestParameters decodeRequest(ClientMessage c public static class ResponseParameters { /** - * True if initialization succeeds, false otherwise. + * true if the ISemaphore is initialized with this call */ public boolean response; } diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreReducePermitsCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreReducePermitsCodec.java deleted file mode 100644 index eeab17b0b9d0d..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreReducePermitsCodec.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Shrinks the number of available permits by the indicated reduction. This method differs from acquire in that it - * does not block waiting for permits to become available. - */ -@Generated({"3392f5281058fb9abdbe5288a3ca1e6b"}) -public final class SemaphoreReducePermitsCodec { - //hex: 0x0D0500 - public static final int REQUEST_MESSAGE_TYPE = 853248; - //hex: 0x0D0501 - public static final int RESPONSE_MESSAGE_TYPE = 853249; - private static final int REQUEST_REDUCTION_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_REDUCTION_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - - private SemaphoreReducePermitsCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * Name of the Semaphore - */ - public java.lang.String name; - - /** - * The number of permits to remove - */ - public int reduction; - } - - public static ClientMessage encodeRequest(java.lang.String name, int reduction) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(false); - clientMessage.setAcquiresResource(true); - clientMessage.setOperationName("Semaphore.ReducePermits"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - encodeInt(initialFrame.content, REQUEST_REDUCTION_FIELD_OFFSET, reduction); - clientMessage.add(initialFrame); - StringCodec.encode(clientMessage, name); - return clientMessage; - } - - public static SemaphoreReducePermitsCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - request.reduction = decodeInt(initialFrame.content, REQUEST_REDUCTION_FIELD_OFFSET); - request.name = StringCodec.decode(iterator); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - } - - public static ClientMessage encodeResponse() { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - return clientMessage; - } - - public static SemaphoreReducePermitsCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - //empty initial frame - iterator.next(); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreReleaseCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreReleaseCodec.java index 15ae09ea878e3..091d45248114c 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreReleaseCodec.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreReleaseCodec.java @@ -33,19 +33,22 @@ */ /** - * Releases the given number of permits, increasing the number of available permits by that amount. There is no - * requirement that a thread that releases a permit must have acquired that permit by calling one of the - * acquire()acquire methods. Correct usage of a semaphore is established by programming convention in the application. + * Releases the given number of permits and increases the number of + * available permits by that amount. */ -@Generated({"76184f1883a74601d1a44f3802898c04"}) +@Generated({"0ec5a0199f91882baacb110e88dfa455"}) public final class SemaphoreReleaseCodec { - //hex: 0x0D0600 - public static final int REQUEST_MESSAGE_TYPE = 853504; - //hex: 0x0D0601 - public static final int RESPONSE_MESSAGE_TYPE = 853505; - private static final int REQUEST_PERMITS_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; + //hex: 0x0D0300 + public static final int REQUEST_MESSAGE_TYPE = 852736; + //hex: 0x0D0301 + public static final int RESPONSE_MESSAGE_TYPE = 852737; + private static final int REQUEST_SESSION_ID_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; + private static final int REQUEST_THREAD_ID_FIELD_OFFSET = REQUEST_SESSION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int REQUEST_INVOCATION_UID_FIELD_OFFSET = REQUEST_THREAD_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int REQUEST_PERMITS_FIELD_OFFSET = REQUEST_INVOCATION_UID_FIELD_OFFSET + UUID_SIZE_IN_BYTES; private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_PERMITS_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; + private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + BOOLEAN_SIZE_IN_BYTES; private SemaphoreReleaseCodec() { } @@ -54,25 +57,49 @@ private SemaphoreReleaseCodec() { public static class RequestParameters { /** - * Name of the Semaphore + * CP group id of this ISemaphore instance + */ + public com.hazelcast.cp.internal.RaftGroupId groupId; + + /** + * Name of this ISemaphore instance */ public java.lang.String name; /** - * The number of permits to remove + * Session ID of the caller + */ + public long sessionId; + + /** + * ID of the caller thread + */ + public long threadId; + + /** + * UID of this invocation + */ + public java.util.UUID invocationUid; + + /** + * number of permits to release */ public int permits; } - public static ClientMessage encodeRequest(java.lang.String name, int permits) { + public static ClientMessage encodeRequest(com.hazelcast.cp.internal.RaftGroupId groupId, java.lang.String name, long sessionId, long threadId, java.util.UUID invocationUid, int permits) { ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(false); - clientMessage.setAcquiresResource(true); + clientMessage.setRetryable(true); + clientMessage.setAcquiresResource(false); clientMessage.setOperationName("Semaphore.Release"); ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); + encodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET, sessionId); + encodeLong(initialFrame.content, REQUEST_THREAD_ID_FIELD_OFFSET, threadId); + encodeUUID(initialFrame.content, REQUEST_INVOCATION_UID_FIELD_OFFSET, invocationUid); encodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET, permits); clientMessage.add(initialFrame); + RaftGroupIdCodec.encode(clientMessage, groupId); StringCodec.encode(clientMessage, name); return clientMessage; } @@ -81,29 +108,39 @@ public static SemaphoreReleaseCodec.RequestParameters decodeRequest(ClientMessag ListIterator iterator = clientMessage.listIterator(); RequestParameters request = new RequestParameters(); ClientMessage.Frame initialFrame = iterator.next(); + request.sessionId = decodeLong(initialFrame.content, REQUEST_SESSION_ID_FIELD_OFFSET); + request.threadId = decodeLong(initialFrame.content, REQUEST_THREAD_ID_FIELD_OFFSET); + request.invocationUid = decodeUUID(initialFrame.content, REQUEST_INVOCATION_UID_FIELD_OFFSET); request.permits = decodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET); + request.groupId = RaftGroupIdCodec.decode(iterator); request.name = StringCodec.decode(iterator); return request; } @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) public static class ResponseParameters { + + /** + * true + */ + public boolean response; } - public static ClientMessage encodeResponse() { + public static ClientMessage encodeResponse(boolean response) { ClientMessage clientMessage = ClientMessage.createForEncode(); ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); clientMessage.add(initialFrame); + encodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET, response); return clientMessage; } public static SemaphoreReleaseCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { ListIterator iterator = clientMessage.listIterator(); ResponseParameters response = new ResponseParameters(); - //empty initial frame - iterator.next(); + ClientMessage.Frame initialFrame = iterator.next(); + response.response = decodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET); return response; } diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreTryAcquireCodec.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreTryAcquireCodec.java deleted file mode 100644 index b77e1bc1df0f0..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/codec/SemaphoreTryAcquireCodec.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.codec; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.builtin.*; - -import javax.annotation.Generated; -import java.util.ListIterator; - -import static com.hazelcast.client.impl.protocol.ClientMessage.*; -import static com.hazelcast.client.impl.protocol.codec.builtin.FixedSizeTypesCodec.*; - -/* - * This file is auto-generated by the Hazelcast Client Protocol Code Generator. - * To change this file, edit the templates or the protocol - * definitions on the https://github.com/hazelcast/hazelcast-client-protocol - * and regenerate it. - */ - -/** - * Acquires the given number of permits, if they are available, and returns immediately, with the value true, - * reducing the number of available permits by the given amount. If insufficient permits are available then this - * method will return immediately with the value false and the number of available permits is unchanged. - */ -@Generated({"8eac83324672701750ea59bb9760ec20"}) -public final class SemaphoreTryAcquireCodec { - //hex: 0x0D0700 - public static final int REQUEST_MESSAGE_TYPE = 853760; - //hex: 0x0D0701 - public static final int RESPONSE_MESSAGE_TYPE = 853761; - private static final int REQUEST_PERMITS_FIELD_OFFSET = PARTITION_ID_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_TIMEOUT_FIELD_OFFSET = REQUEST_PERMITS_FIELD_OFFSET + INT_SIZE_IN_BYTES; - private static final int REQUEST_INITIAL_FRAME_SIZE = REQUEST_TIMEOUT_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int RESPONSE_RESPONSE_FIELD_OFFSET = CORRELATION_ID_FIELD_OFFSET + LONG_SIZE_IN_BYTES; - private static final int RESPONSE_INITIAL_FRAME_SIZE = RESPONSE_RESPONSE_FIELD_OFFSET + BOOLEAN_SIZE_IN_BYTES; - - private SemaphoreTryAcquireCodec() { - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class RequestParameters { - - /** - * Name of the Semaphore - */ - public java.lang.String name; - - /** - * The number of permits to remove - */ - public int permits; - - /** - * The maximum time to wait for a permit - */ - public long timeout; - } - - public static ClientMessage encodeRequest(java.lang.String name, int permits, long timeout) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - clientMessage.setRetryable(false); - clientMessage.setAcquiresResource(true); - clientMessage.setOperationName("Semaphore.TryAcquire"); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[REQUEST_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, REQUEST_MESSAGE_TYPE); - encodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET, permits); - encodeLong(initialFrame.content, REQUEST_TIMEOUT_FIELD_OFFSET, timeout); - clientMessage.add(initialFrame); - StringCodec.encode(clientMessage, name); - return clientMessage; - } - - public static SemaphoreTryAcquireCodec.RequestParameters decodeRequest(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - RequestParameters request = new RequestParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - request.permits = decodeInt(initialFrame.content, REQUEST_PERMITS_FIELD_OFFSET); - request.timeout = decodeLong(initialFrame.content, REQUEST_TIMEOUT_FIELD_OFFSET); - request.name = StringCodec.decode(iterator); - return request; - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"}) - public static class ResponseParameters { - - /** - * true if all permits were acquired, false if the waiting time elapsed before all permits could be acquired - */ - public boolean response; - } - - public static ClientMessage encodeResponse(boolean response) { - ClientMessage clientMessage = ClientMessage.createForEncode(); - ClientMessage.Frame initialFrame = new ClientMessage.Frame(new byte[RESPONSE_INITIAL_FRAME_SIZE], UNFRAGMENTED_MESSAGE); - encodeInt(initialFrame.content, TYPE_FIELD_OFFSET, RESPONSE_MESSAGE_TYPE); - clientMessage.add(initialFrame); - - encodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET, response); - return clientMessage; - } - - public static SemaphoreTryAcquireCodec.ResponseParameters decodeResponse(ClientMessage clientMessage) { - ListIterator iterator = clientMessage.listIterator(); - ResponseParameters response = new ResponseParameters(); - ClientMessage.Frame initialFrame = iterator.next(); - response.response = decodeBoolean(initialFrame.content, RESPONSE_RESPONSE_FIELD_OFFSET); - return response; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/dynamicconfig/AddSemaphoreConfigMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/dynamicconfig/AddSemaphoreConfigMessageTask.java deleted file mode 100644 index 410de7aaeab36..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/dynamicconfig/AddSemaphoreConfigMessageTask.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.dynamicconfig; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddSemaphoreConfigCodec; -import com.hazelcast.client.impl.protocol.codec.DynamicConfigAddSetConfigCodec; -import com.hazelcast.config.SemaphoreConfig; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.nio.serialization.IdentifiedDataSerializable; - -public class AddSemaphoreConfigMessageTask - extends AbstractAddConfigMessageTask { - - public AddSemaphoreConfigMessageTask(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected DynamicConfigAddSemaphoreConfigCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return DynamicConfigAddSemaphoreConfigCodec.decodeRequest(clientMessage); - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return DynamicConfigAddSetConfigCodec.encodeResponse(); - } - - @Override - protected IdentifiedDataSerializable getConfig() { - SemaphoreConfig config = new SemaphoreConfig(); - config.setName(parameters.name); - config.setBackupCount(parameters.backupCount); - config.setAsyncBackupCount(parameters.asyncBackupCount); - config.setInitialPermits(parameters.initialPermits); - return config; - } - - @Override - public String getMethodName() { - return "addSemaphoreConfig"; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreAcquireMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreAcquireMessageTask.java deleted file mode 100644 index 604713e469641..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreAcquireMessageTask.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.semaphore; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreAcquireCodec; -import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.AcquireOperation; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.security.permission.ActionConstants; -import com.hazelcast.security.permission.SemaphorePermission; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.security.Permission; - - -public class SemaphoreAcquireMessageTask - extends AbstractPartitionMessageTask { - - public SemaphoreAcquireMessageTask(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected Operation prepareOperation() { - return new AcquireOperation(parameters.name, parameters.permits, -1); - } - - @Override - protected SemaphoreAcquireCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return SemaphoreAcquireCodec.decodeRequest(clientMessage); - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return SemaphoreAcquireCodec.encodeResponse(); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public Permission getRequiredPermission() { - return new SemaphorePermission(parameters.name, ActionConstants.ACTION_ACQUIRE); - } - - @Override - public String getDistributedObjectName() { - return parameters.name; - } - - @Override - public String getMethodName() { - return "acquire"; - } - - @Override - public Object[] getParameters() { - return new Object[]{parameters.permits}; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreAvailablePermitsMessageTasks.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreAvailablePermitsMessageTasks.java deleted file mode 100644 index 427c4803fc6c6..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreAvailablePermitsMessageTasks.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.semaphore; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreAvailablePermitsCodec; -import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.AvailableOperation; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.security.permission.ActionConstants; -import com.hazelcast.security.permission.SemaphorePermission; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.security.Permission; - -public class SemaphoreAvailablePermitsMessageTasks - extends AbstractPartitionMessageTask { - - public SemaphoreAvailablePermitsMessageTasks(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected Operation prepareOperation() { - return new AvailableOperation(parameters.name); - } - - @Override - protected SemaphoreAvailablePermitsCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return SemaphoreAvailablePermitsCodec.decodeRequest(clientMessage); - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return SemaphoreAvailablePermitsCodec.encodeResponse((Integer) response); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public Permission getRequiredPermission() { - return new SemaphorePermission(parameters.name, ActionConstants.ACTION_READ); - } - - @Override - public String getDistributedObjectName() { - return parameters.name; - } - - @Override - public String getMethodName() { - return "availablePermits"; - } - - @Override - public Object[] getParameters() { - return null; - } - -} - diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreDrainPermitsMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreDrainPermitsMessageTask.java deleted file mode 100644 index f0c3d66adf1f2..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreDrainPermitsMessageTask.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.semaphore; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreDrainPermitsCodec; -import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.DrainOperation; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.security.permission.ActionConstants; -import com.hazelcast.security.permission.SemaphorePermission; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.security.Permission; - -public class SemaphoreDrainPermitsMessageTask - extends AbstractPartitionMessageTask { - - public SemaphoreDrainPermitsMessageTask(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected Operation prepareOperation() { - return new DrainOperation(parameters.name); - } - - @Override - protected SemaphoreDrainPermitsCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return SemaphoreDrainPermitsCodec.decodeRequest(clientMessage); - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return SemaphoreDrainPermitsCodec.encodeResponse((Integer) response); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public Permission getRequiredPermission() { - return new SemaphorePermission(parameters.name, ActionConstants.ACTION_ACQUIRE); - } - - @Override - public String getDistributedObjectName() { - return parameters.name; - } - - @Override - public String getMethodName() { - return "drainPermits"; - } - - @Override - public Object[] getParameters() { - return null; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreIncreasePermitsMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreIncreasePermitsMessageTask.java deleted file mode 100644 index 22a9141191b66..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreIncreasePermitsMessageTask.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.semaphore; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreIncreasePermitsCodec; -import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.IncreaseOperation; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.security.permission.ActionConstants; -import com.hazelcast.security.permission.SemaphorePermission; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.security.Permission; - -public class SemaphoreIncreasePermitsMessageTask - extends AbstractPartitionMessageTask { - - public SemaphoreIncreasePermitsMessageTask(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected Operation prepareOperation() { - return new IncreaseOperation(parameters.name, parameters.increase); - } - - @Override - protected SemaphoreIncreasePermitsCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return SemaphoreIncreasePermitsCodec.decodeRequest(clientMessage); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return SemaphoreIncreasePermitsCodec.encodeResponse(); - } - - @Override - public Permission getRequiredPermission() { - return new SemaphorePermission(parameters.name, ActionConstants.ACTION_ACQUIRE); - } - - @Override - public String getDistributedObjectName() { - return parameters.name; - } - - @Override - public String getMethodName() { - return "increasePermits"; - } - - @Override - public Object[] getParameters() { - return new Object[]{parameters.increase}; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreInitMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreInitMessageTask.java deleted file mode 100644 index 515809a617780..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreInitMessageTask.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.semaphore; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreInitCodec; -import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.InitOperation; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.security.permission.ActionConstants; -import com.hazelcast.security.permission.SemaphorePermission; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.security.Permission; - -public class SemaphoreInitMessageTask - extends AbstractPartitionMessageTask { - - public SemaphoreInitMessageTask(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected Operation prepareOperation() { - return new InitOperation(parameters.name, parameters.permits); - } - - @Override - protected SemaphoreInitCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return SemaphoreInitCodec.decodeRequest(clientMessage); - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return SemaphoreInitCodec.encodeResponse((Boolean) response); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public Permission getRequiredPermission() { - return new SemaphorePermission(parameters.name, ActionConstants.ACTION_RELEASE); - } - - @Override - public String getDistributedObjectName() { - return parameters.name; - } - - @Override - public String getMethodName() { - return "init"; - } - - @Override - public Object[] getParameters() { - return new Object[]{parameters.permits}; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreReducePermitsMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreReducePermitsMessageTask.java deleted file mode 100644 index f28a47e16f9b6..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreReducePermitsMessageTask.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.semaphore; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreReducePermitsCodec; -import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.ReduceOperation; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.security.permission.ActionConstants; -import com.hazelcast.security.permission.SemaphorePermission; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.security.Permission; - -public class SemaphoreReducePermitsMessageTask - extends AbstractPartitionMessageTask { - - public SemaphoreReducePermitsMessageTask(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected Operation prepareOperation() { - return new ReduceOperation(parameters.name, parameters.reduction); - } - - @Override - protected SemaphoreReducePermitsCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return SemaphoreReducePermitsCodec.decodeRequest(clientMessage); - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return SemaphoreReducePermitsCodec.encodeResponse(); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public Permission getRequiredPermission() { - return new SemaphorePermission(parameters.name, ActionConstants.ACTION_ACQUIRE); - } - - @Override - public String getDistributedObjectName() { - return parameters.name; - } - - @Override - public String getMethodName() { - return "reducePermits"; - } - - @Override - public Object[] getParameters() { - return new Object[]{parameters.reduction}; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreReleaseMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreReleaseMessageTask.java deleted file mode 100644 index 70d20f973f909..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreReleaseMessageTask.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.semaphore; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreReleaseCodec; -import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.ReleaseOperation; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.security.permission.ActionConstants; -import com.hazelcast.security.permission.SemaphorePermission; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.security.Permission; - -public class SemaphoreReleaseMessageTask - extends AbstractPartitionMessageTask { - - public SemaphoreReleaseMessageTask(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected Operation prepareOperation() { - return new ReleaseOperation(parameters.name, parameters.permits); - } - - @Override - protected SemaphoreReleaseCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return SemaphoreReleaseCodec.decodeRequest(clientMessage); - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return SemaphoreReleaseCodec.encodeResponse(); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public Permission getRequiredPermission() { - return new SemaphorePermission(parameters.name, ActionConstants.ACTION_RELEASE); - } - - @Override - public String getDistributedObjectName() { - return parameters.name; - } - - @Override - public String getMethodName() { - return "release"; - } - - @Override - public Object[] getParameters() { - return new Object[]{parameters.permits}; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreTryAcquireMessageTask.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreTryAcquireMessageTask.java deleted file mode 100644 index b642f9e3a3730..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/SemaphoreTryAcquireMessageTask.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.protocol.task.semaphore; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreTryAcquireCodec; -import com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.AcquireOperation; -import com.hazelcast.instance.impl.Node; -import com.hazelcast.nio.Connection; -import com.hazelcast.security.permission.ActionConstants; -import com.hazelcast.security.permission.SemaphorePermission; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.security.Permission; -import java.util.concurrent.TimeUnit; - -public class SemaphoreTryAcquireMessageTask - extends AbstractPartitionMessageTask { - - public SemaphoreTryAcquireMessageTask(ClientMessage clientMessage, Node node, Connection connection) { - super(clientMessage, node, connection); - } - - @Override - protected Operation prepareOperation() { - return new AcquireOperation(parameters.name, parameters.permits, parameters.timeout); - } - - @Override - protected SemaphoreTryAcquireCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return SemaphoreTryAcquireCodec.decodeRequest(clientMessage); - } - - @Override - protected ClientMessage encodeResponse(Object response) { - return SemaphoreTryAcquireCodec.encodeResponse((Boolean) response); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public Permission getRequiredPermission() { - return new SemaphorePermission(parameters.name, ActionConstants.ACTION_ACQUIRE); - } - - @Override - public String getDistributedObjectName() { - return parameters.name; - } - - @Override - public String getMethodName() { - return "tryAcquire"; - } - - @Override - public Object[] getParameters() { - if (parameters.timeout > 0) { - return new Object[]{parameters.permits, parameters.timeout, TimeUnit.MILLISECONDS}; - } - return new Object[]{parameters.permits}; - } -} - diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/package-info.java b/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/package-info.java deleted file mode 100644 index 6536bb1175d10..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/protocol/task/semaphore/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - *

Client protocol tasks implementations for Semaphore

- */ - -package com.hazelcast.client.impl.protocol.task.semaphore; diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/proxy/ClientSemaphoreProxy.java b/hazelcast/src/main/java/com/hazelcast/client/impl/proxy/ClientSemaphoreProxy.java deleted file mode 100644 index d2483ac8ec079..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/proxy/ClientSemaphoreProxy.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.client.impl.proxy; - -import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.SemaphoreAcquireCodec; -import com.hazelcast.client.impl.protocol.codec.SemaphoreAvailablePermitsCodec; -import com.hazelcast.client.impl.protocol.codec.SemaphoreDrainPermitsCodec; -import com.hazelcast.client.impl.protocol.codec.SemaphoreIncreasePermitsCodec; -import com.hazelcast.client.impl.protocol.codec.SemaphoreInitCodec; -import com.hazelcast.client.impl.protocol.codec.SemaphoreReducePermitsCodec; -import com.hazelcast.client.impl.protocol.codec.SemaphoreReleaseCodec; -import com.hazelcast.client.impl.protocol.codec.SemaphoreTryAcquireCodec; -import com.hazelcast.client.impl.spi.ClientContext; -import com.hazelcast.cp.ISemaphore; - -import java.util.concurrent.TimeUnit; - -import static java.lang.Thread.currentThread; - -/** - * Proxy implementation of {@link ISemaphore}. - */ -public class ClientSemaphoreProxy extends PartitionSpecificClientProxy implements ISemaphore { - - public ClientSemaphoreProxy(String serviceName, String objectId, ClientContext context) { - super(serviceName, objectId, context); - } - - @Override - public boolean init(int permits) { - checkNegative(permits); - ClientMessage request = SemaphoreInitCodec.encodeRequest(name, permits); - ClientMessage response = invokeOnPartition(request); - SemaphoreInitCodec.ResponseParameters resultParameters = SemaphoreInitCodec.decodeResponse(response); - - return resultParameters.response; - } - - @Override - public void acquire() throws InterruptedException { - ClientMessage request = SemaphoreAcquireCodec.encodeRequest(name, 1); - invokeOnPartition(request); - } - - @Override - public void acquire(int permits) throws InterruptedException { - checkNegative(permits); - ClientMessage request = SemaphoreAcquireCodec.encodeRequest(name, permits); - invokeOnPartition(request); - } - - @Override - public int availablePermits() { - ClientMessage request = SemaphoreAvailablePermitsCodec.encodeRequest(name); - ClientMessage response = invokeOnPartition(request); - SemaphoreAvailablePermitsCodec.ResponseParameters resultParameters - = SemaphoreAvailablePermitsCodec.decodeResponse(response); - return resultParameters.response; - } - - @Override - public int drainPermits() { - ClientMessage request = SemaphoreDrainPermitsCodec.encodeRequest(name); - ClientMessage response = invokeOnPartition(request); - SemaphoreDrainPermitsCodec.ResponseParameters resultParameters - = SemaphoreDrainPermitsCodec.decodeResponse(response); - return resultParameters.response; - } - - @Override - public void reducePermits(int reduction) { - checkNegative(reduction); - ClientMessage request = SemaphoreReducePermitsCodec.encodeRequest(name, reduction); - invokeOnPartition(request); - } - - @Override - public void increasePermits(int increase) { - checkNegative(increase); - ClientMessage request = SemaphoreIncreasePermitsCodec.encodeRequest(name, increase); - invokeOnPartition(request); - } - - @Override - public void release() { - ClientMessage request = SemaphoreReleaseCodec.encodeRequest(name, 1); - invokeOnPartition(request); - } - - @Override - public void release(int permits) { - checkNegative(permits); - ClientMessage request = SemaphoreReleaseCodec.encodeRequest(name, permits); - invokeOnPartition(request); - } - - @Override - public boolean tryAcquire() { - ClientMessage request = SemaphoreTryAcquireCodec.encodeRequest(name, 1, 0); - ClientMessage response = invokeOnPartition(request); - SemaphoreTryAcquireCodec.ResponseParameters resultParameters = SemaphoreTryAcquireCodec.decodeResponse(response); - return resultParameters.response; - } - - @Override - public boolean tryAcquire(int permits) { - checkNegative(permits); - try { - return tryAcquire(permits, 0, TimeUnit.SECONDS); - } catch (InterruptedException e) { - currentThread().interrupt(); - return false; - } - } - - @Override - public boolean tryAcquire(long timeout, TimeUnit unit) throws InterruptedException { - if (timeout == 0) { - return tryAcquire(); - } - ClientMessage request = SemaphoreTryAcquireCodec.encodeRequest(name, 1, unit.toMillis(timeout)); - ClientMessage response = invokeOnPartition(request); - SemaphoreTryAcquireCodec.ResponseParameters resultParameters = SemaphoreTryAcquireCodec.decodeResponse(response); - return resultParameters.response; - } - - @Override - public boolean tryAcquire(int permits, long timeout, TimeUnit unit) throws InterruptedException { - checkNegative(permits); - ClientMessage request = SemaphoreTryAcquireCodec.encodeRequest(name, permits, unit.toMillis(timeout)); - ClientMessage response = invokeOnPartition(request); - SemaphoreTryAcquireCodec.ResponseParameters resultParameters = SemaphoreTryAcquireCodec.decodeResponse(response); - return resultParameters.response; - } - - private void checkNegative(int permits) { - if (permits < 0) { - throw new IllegalArgumentException("Permits cannot be negative!"); - } - } - - @Override - public String toString() { - return "ISemaphore{" + "name='" + name + '\'' + '}'; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/spi/ProxyManager.java b/hazelcast/src/main/java/com/hazelcast/client/impl/spi/ProxyManager.java index 64849d89313c9..de9dec888a0f1 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/spi/ProxyManager.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/spi/ProxyManager.java @@ -47,7 +47,6 @@ import com.hazelcast.client.impl.proxy.ClientReplicatedMapProxy; import com.hazelcast.client.impl.proxy.ClientRingbufferProxy; import com.hazelcast.client.impl.proxy.ClientScheduledExecutorProxy; -import com.hazelcast.client.impl.proxy.ClientSemaphoreProxy; import com.hazelcast.client.impl.proxy.ClientSetProxy; import com.hazelcast.client.impl.proxy.ClientTopicProxy; import com.hazelcast.client.impl.proxy.txn.xa.XAResourceProxy; @@ -72,11 +71,12 @@ import com.hazelcast.cp.internal.datastructures.unsafe.atomicreference.AtomicReferenceService; import com.hazelcast.cp.internal.datastructures.unsafe.idgen.IdGeneratorService; import com.hazelcast.cp.internal.datastructures.unsafe.lock.LockServiceImpl; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; import com.hazelcast.crdt.pncounter.PNCounterService; import com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService; import com.hazelcast.executor.impl.DistributedExecutorService; import com.hazelcast.flakeidgen.impl.FlakeIdGeneratorService; +import com.hazelcast.internal.services.DistributedObjectNamespace; +import com.hazelcast.internal.services.ObjectNamespace; import com.hazelcast.map.impl.MapService; import com.hazelcast.multimap.impl.MultiMapService; import com.hazelcast.nio.Address; @@ -85,8 +85,6 @@ import com.hazelcast.replicatedmap.impl.ReplicatedMapService; import com.hazelcast.ringbuffer.impl.RingbufferService; import com.hazelcast.scheduledexecutor.impl.DistributedScheduledExecutorService; -import com.hazelcast.internal.services.DistributedObjectNamespace; -import com.hazelcast.internal.services.ObjectNamespace; import com.hazelcast.topic.impl.TopicService; import com.hazelcast.topic.impl.reliable.ReliableTopicService; import com.hazelcast.transaction.impl.xa.XAService; @@ -177,7 +175,6 @@ public void init(ClientConfig config, ClientContext clientContext) { register(MultiMapService.SERVICE_NAME, ClientMultiMapProxy.class); register(ListService.SERVICE_NAME, ClientListProxy.class); register(SetService.SERVICE_NAME, ClientSetProxy.class); - register(SemaphoreService.SERVICE_NAME, ClientSemaphoreProxy.class); register(TopicService.SERVICE_NAME, ClientTopicProxy.class); register(AtomicLongService.SERVICE_NAME, ClientAtomicLongProxy.class); register(AtomicReferenceService.SERVICE_NAME, ClientAtomicReferenceProxy.class); diff --git a/hazelcast/src/main/java/com/hazelcast/config/Config.java b/hazelcast/src/main/java/com/hazelcast/config/Config.java index bab96c1a49248..d3bb7557ec383 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/Config.java +++ b/hazelcast/src/main/java/com/hazelcast/config/Config.java @@ -23,7 +23,6 @@ import com.hazelcast.config.matcher.MatchingPointConfigPatternMatcher; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.ManagedContext; -import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.lock.ILock; import com.hazelcast.flakeidgen.FlakeIdGenerator; import com.hazelcast.internal.config.ConfigUtils; @@ -36,7 +35,6 @@ import java.io.File; import java.net.URL; -import java.util.Collection; import java.util.EventListener; import java.util.LinkedList; import java.util.List; @@ -106,8 +104,6 @@ public class Config { private final Map scheduledExecutorConfigs = new ConcurrentHashMap(); - private final Map semaphoreConfigs = new ConcurrentHashMap(); - private final Map replicatedMapConfigs = new ConcurrentHashMap(); private final Map wanReplicationConfigs = new ConcurrentHashMap(); @@ -2210,117 +2206,6 @@ public Config setPNCounterConfigs(Map pnCounterConfigs) return this; } - /** - * Returns a read-only {@link ISemaphore} - * configuration for the given name. - *

- * The name is matched by pattern to the configuration and by stripping the - * partition ID qualifier from the given {@code name}. - * If there is no config found by the name, it will return the configuration - * with the name {@code default}. - * - * @param name name of the semaphore config - * @return the semaphore configuration - * @throws InvalidConfigurationException if ambiguous configurations are - * found - * @see StringPartitioningStrategy#getBaseName(java.lang.String) - * @see #setConfigPatternMatcher(ConfigPatternMatcher) - * @see #getConfigPatternMatcher() - * @see EvictionConfig#setSize(int) - */ - public SemaphoreConfig findSemaphoreConfig(String name) { - name = getBaseName(name); - SemaphoreConfig config = lookupByPattern(configPatternMatcher, semaphoreConfigs, name); - if (config != null) { - return config.getAsReadOnly(); - } - return getSemaphoreConfig("default").getAsReadOnly(); - } - - /** - * Returns the SemaphoreConfig for the given name, creating one - * if necessary and adding it to the collection of known configurations. - *

- * The configuration is found by matching the configuration name - * pattern to the provided {@code name} without the partition qualifier - * (the part of the name after {@code '@'}). - * If no configuration matches, it will create one by cloning the - * {@code "default"} configuration and add it to the configuration - * collection. - *

- * This method is intended to easily and fluently create and add - * configurations more specific than the default configuration without - * explicitly adding it by invoking - * {@link #addSemaphoreConfig(SemaphoreConfig)}. - *

- * Because it adds new configurations if they are not already present, - * this method is intended to be used before this config is used to - * create a hazelcast instance. Afterwards, newly added configurations - * may be ignored. - * - * @param name name of the semaphore config - * @return the semaphore configuration - * @throws InvalidConfigurationException if ambiguous configurations are - * found - * @see StringPartitioningStrategy#getBaseName(java.lang.String) - * @see #setConfigPatternMatcher(ConfigPatternMatcher) - * @see #getConfigPatternMatcher() - */ - public SemaphoreConfig getSemaphoreConfig(String name) { - return ConfigUtils.getConfig(configPatternMatcher, semaphoreConfigs, name, SemaphoreConfig.class); - } - - /** - * Adds the {@link ISemaphore} configuration. - * The configuration is saved under the config name, which may be a - * pattern with which the configuration will be obtained in the future. - * - * @param semaphoreConfig semaphoreConfig config to add - * @return this config instance - */ - public Config addSemaphoreConfig(SemaphoreConfig semaphoreConfig) { - this.semaphoreConfigs.put(semaphoreConfig.getName(), semaphoreConfig); - return this; - } - - /** - * Returns the collection of {@link ISemaphore} configs - * added to this config object. - * - * @return semaphore configs - */ - public Collection getSemaphoreConfigs() { - return semaphoreConfigs.values(); - } - - /** - * Returns the map of {@link ISemaphore} configurations, - * mapped by config name. The config name may be a pattern with which the - * configuration was initially obtained. - * - * @return the semaphore configurations mapped by config name - */ - public Map getSemaphoreConfigsAsMap() { - return semaphoreConfigs; - } - - /** - * Sets the map of semaphore configurations, mapped by config name. - * The config name may be a pattern with which the configuration will be - * obtained in the future. - * - * @param semaphoreConfigs the semaphore configuration map to set - * @return this config instance - */ - public Config setSemaphoreConfigs(Map semaphoreConfigs) { - this.semaphoreConfigs.clear(); - this.semaphoreConfigs.putAll(semaphoreConfigs); - for (final Entry entry : this.semaphoreConfigs.entrySet()) { - entry.getValue().setName(entry.getKey()); - } - return this; - } - /** * Returns the WAN replication configuration with the given {@code name}. * @@ -3005,7 +2890,6 @@ public String toString() { + ", queueConfigs=" + queueConfigs + ", multiMapConfigs=" + multiMapConfigs + ", executorConfigs=" + executorConfigs - + ", semaphoreConfigs=" + semaphoreConfigs + ", ringbufferConfigs=" + ringbufferConfigs + ", atomicLongConfigs=" + atomicLongConfigs + ", atomicReferenceConfigs=" + atomicReferenceConfigs diff --git a/hazelcast/src/main/java/com/hazelcast/config/ConfigDataSerializerHook.java b/hazelcast/src/main/java/com/hazelcast/config/ConfigDataSerializerHook.java index bb7e7b4888524..f475e8c797f77 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/ConfigDataSerializerHook.java +++ b/hazelcast/src/main/java/com/hazelcast/config/ConfigDataSerializerHook.java @@ -149,7 +149,6 @@ public DataSerializableFactory createFactory() { constructors[EXECUTOR_CONFIG] = arg -> new ExecutorConfig(); constructors[DURABLE_EXECUTOR_CONFIG] = arg -> new DurableExecutorConfig(); constructors[SCHEDULED_EXECUTOR_CONFIG] = arg -> new ScheduledExecutorConfig(); - constructors[SEMAPHORE_CONFIG] = arg -> new SemaphoreConfig(); constructors[REPLICATED_MAP_CONFIG] = arg -> new ReplicatedMapConfig(); constructors[RINGBUFFER_CONFIG] = arg -> new RingbufferConfig(); constructors[RINGBUFFER_STORE_CONFIG] = arg -> new RingbufferStoreConfig(); diff --git a/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java b/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java index 59cbbcfe8ae66..8351aead7f7c4 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java +++ b/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java @@ -19,7 +19,7 @@ import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig; import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.DurationConfig; import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig; -import com.hazelcast.config.cp.CPSemaphoreConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.config.cp.RaftAlgorithmConfig; @@ -140,7 +140,6 @@ public String generate(Config config) { collectionXmlGenerator(gen, "list", config.getListConfigs().values()); collectionXmlGenerator(gen, "set", config.getSetConfigs().values()); topicXmlGenerator(gen, config); - semaphoreXmlGenerator(gen, config); lockXmlGenerator(gen, config); ringbufferXmlGenerator(gen, config); atomicLongXmlGenerator(gen, config); @@ -490,17 +489,6 @@ private static void pnCounterXmlGenerator(XmlGenerator gen, Config config) { } } - private static void semaphoreXmlGenerator(XmlGenerator gen, Config config) { - for (SemaphoreConfig sc : config.getSemaphoreConfigs()) { - gen.open("semaphore", "name", sc.getName()) - .node("initial-permits", sc.getInitialPermits()) - .node("backup-count", sc.getBackupCount()) - .node("async-backup-count", sc.getAsyncBackupCount()) - .node("split-brain-protection-ref", sc.getSplitBrainProtectionName()) - .close(); - } - } - private static void topicXmlGenerator(XmlGenerator gen, Config config) { for (TopicConfig t : config.getTopicConfigs().values()) { gen.open("topic", "name", t.getName()) @@ -1449,8 +1437,8 @@ private static void cpSubsystemConfig(XmlGenerator gen, Config config) { gen.open("semaphores"); - for (CPSemaphoreConfig semaphoreConfig : cpSubsystemConfig.getSemaphoreConfigs().values()) { - gen.open("cp-semaphore") + for (SemaphoreConfig semaphoreConfig : cpSubsystemConfig.getSemaphoreConfigs().values()) { + gen.open("semaphore") .node("name", semaphoreConfig.getName()) .node("jdk-compatible", semaphoreConfig.isJDKCompatible()) .close(); diff --git a/hazelcast/src/main/java/com/hazelcast/config/MemberDomConfigProcessor.java b/hazelcast/src/main/java/com/hazelcast/config/MemberDomConfigProcessor.java index b27ba44ce1647..317ba4124b0ec 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/MemberDomConfigProcessor.java +++ b/hazelcast/src/main/java/com/hazelcast/config/MemberDomConfigProcessor.java @@ -17,7 +17,7 @@ package com.hazelcast.config; import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig.ExpiryPolicyType; -import com.hazelcast.config.cp.CPSemaphoreConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.config.cp.RaftAlgorithmConfig; @@ -76,16 +76,15 @@ import static com.hazelcast.config.ConfigSections.PN_COUNTER; import static com.hazelcast.config.ConfigSections.PROPERTIES; import static com.hazelcast.config.ConfigSections.QUEUE; -import static com.hazelcast.config.ConfigSections.SPLIT_BRAIN_PROTECTION; import static com.hazelcast.config.ConfigSections.RELIABLE_TOPIC; import static com.hazelcast.config.ConfigSections.REPLICATED_MAP; import static com.hazelcast.config.ConfigSections.RINGBUFFER; import static com.hazelcast.config.ConfigSections.SCHEDULED_EXECUTOR_SERVICE; import static com.hazelcast.config.ConfigSections.SECURITY; -import static com.hazelcast.config.ConfigSections.SEMAPHORE; import static com.hazelcast.config.ConfigSections.SERIALIZATION; import static com.hazelcast.config.ConfigSections.SERVICES; import static com.hazelcast.config.ConfigSections.SET; +import static com.hazelcast.config.ConfigSections.SPLIT_BRAIN_PROTECTION; import static com.hazelcast.config.ConfigSections.TOPIC; import static com.hazelcast.config.ConfigSections.USER_CODE_DEPLOYMENT; import static com.hazelcast.config.ConfigSections.WAN_REPLICATION; @@ -186,8 +185,6 @@ private boolean handleNode(Node node, String nodeName) throws Exception { handleCache(node); } else if (NATIVE_MEMORY.isEqual(nodeName)) { fillNativeMemoryConfig(node, config.getNativeMemoryConfig()); - } else if (SEMAPHORE.isEqual(nodeName)) { - handleSemaphore(node); } else if (LOCK.isEqual(nodeName)) { handleLock(node); } else if (RINGBUFFER.isEqual(nodeName)) { @@ -2355,33 +2352,6 @@ void handleMessageListeners(Node n, Function configAddFunc } } - protected void handleSemaphore(Node node) { - Node attName = node.getAttributes().getNamedItem("name"); - String name = getTextContent(attName); - SemaphoreConfig sConfig = new SemaphoreConfig(); - sConfig.setName(name); - handleSemaphoreNode(node, sConfig); - } - - void handleSemaphoreNode(Node node, SemaphoreConfig sConfig) { - for (Node n : childElements(node)) { - String nodeName = cleanNodeName(n); - String value = getTextContent(n).trim(); - if ("initial-permits".equals(nodeName)) { - sConfig.setInitialPermits(getIntegerValue("initial-permits", value)); - } else if ("backup-count".equals(nodeName)) { - sConfig.setBackupCount(getIntegerValue("backup-count" - , value)); - } else if ("async-backup-count".equals(nodeName)) { - sConfig.setAsyncBackupCount(getIntegerValue("async-backup-count" - , value)); - } else if ("split-brain-protection-ref".equals(nodeName)) { - sConfig.setSplitBrainProtectionName(value); - } - } - config.addSemaphoreConfig(sConfig); - } - protected void handleRingbuffer(Node node) { Node attName = node.getAttributes().getNamedItem("name"); String name = getTextContent(attName); @@ -2848,7 +2818,7 @@ private void handleCPSubsystem(Node node) { if ("raft-algorithm".equals(nodeName)) { handleRaftAlgorithm(cpSubsystemConfig.getRaftAlgorithmConfig(), child); } else if ("semaphores".equals(nodeName)) { - handleCPSemaphores(cpSubsystemConfig, child); + handleSemaphores(cpSubsystemConfig, child); } else if ("locks".equals(nodeName)) { handleFencedLocks(cpSubsystemConfig, child); } else { @@ -2892,19 +2862,19 @@ private void handleRaftAlgorithm(RaftAlgorithmConfig raftAlgorithmConfig, Node n } } - void handleCPSemaphores(CPSubsystemConfig cpSubsystemConfig, Node node) { + void handleSemaphores(CPSubsystemConfig cpSubsystemConfig, Node node) { for (Node child : childElements(node)) { - CPSemaphoreConfig cpSemaphoreConfig = new CPSemaphoreConfig(); + SemaphoreConfig semaphoreConfig = new SemaphoreConfig(); for (Node subChild : childElements(child)) { String nodeName = cleanNodeName(subChild); String value = getTextContent(subChild).trim(); if ("name".equals(nodeName)) { - cpSemaphoreConfig.setName(value); + semaphoreConfig.setName(value); } else if ("jdk-compatible".equals(nodeName)) { - cpSemaphoreConfig.setJDKCompatible(Boolean.parseBoolean(value)); + semaphoreConfig.setJDKCompatible(Boolean.parseBoolean(value)); } } - cpSubsystemConfig.addSemaphoreConfig(cpSemaphoreConfig); + cpSubsystemConfig.addSemaphoreConfig(semaphoreConfig); } } diff --git a/hazelcast/src/main/java/com/hazelcast/config/SemaphoreConfig.java b/hazelcast/src/main/java/com/hazelcast/config/SemaphoreConfig.java deleted file mode 100644 index 049e61ccc9232..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/config/SemaphoreConfig.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.config; - -import com.hazelcast.cp.ISemaphore; -import com.hazelcast.nio.ObjectDataInput; -import com.hazelcast.nio.ObjectDataOutput; -import com.hazelcast.nio.serialization.IdentifiedDataSerializable; - -import java.io.IOException; - -import static com.hazelcast.internal.util.Preconditions.checkAsyncBackupCount; -import static com.hazelcast.internal.util.Preconditions.checkBackupCount; -import static com.hazelcast.internal.util.Preconditions.checkHasText; -import static com.hazelcast.internal.util.Preconditions.isNotNull; - -/** - * Contains the configuration for an {@link ISemaphore}. - */ -public class SemaphoreConfig implements IdentifiedDataSerializable, NamedConfig { - - /** - * Default synchronous backup count. - */ - public static final int DEFAULT_SYNC_BACKUP_COUNT = 1; - /** - * Default asynchronous backup count. - */ - public static final int DEFAULT_ASYNC_BACKUP_COUNT = 0; - - private String name; - private int initialPermits; - private int backupCount = DEFAULT_SYNC_BACKUP_COUNT; - private int asyncBackupCount = DEFAULT_ASYNC_BACKUP_COUNT; - private transient SemaphoreConfigReadOnly readOnly; - - private String splitBrainProtectionName; - - /** - * Creates a default configured {@link SemaphoreConfig}. - */ - public SemaphoreConfig() { - } - - /** - * Creates a SemaphoreConfig by cloning another one. - * - * @param config the SemaphoreConfig to copy - * @throws IllegalArgumentException if config is {@code null} - */ - public SemaphoreConfig(SemaphoreConfig config) { - isNotNull(config, "config"); - this.name = config.getName(); - this.initialPermits = config.getInitialPermits(); - this.backupCount = config.getBackupCount(); - this.asyncBackupCount = config.getAsyncBackupCount(); - this.splitBrainProtectionName = config.getSplitBrainProtectionName(); - } - - /** - * Gets immutable version of this configuration. - * - * @return immutable version of this configuration - * @deprecated this method will be removed in 4.0; it is meant for internal usage only - */ - public SemaphoreConfigReadOnly getAsReadOnly() { - if (readOnly == null) { - readOnly = new SemaphoreConfigReadOnly(this); - } - return readOnly; - } - - /** - * Gets the name of the semaphore. If no name has been configured, {@code null} is returned. - * - * @return the name of the semaphore - */ - public String getName() { - return name; - } - - /** - * Sets the name of the semaphore. - * - * @param name the name of the semaphore - * @return the updated SemaphoreConfig - * @throws IllegalArgumentException if name is {@code null} or empty - */ - public SemaphoreConfig setName(String name) { - this.name = checkHasText(name, "name must contain text"); - return this; - } - - /** - * Gets the initial number of permits. - * - * @return the initial number of permits - */ - public int getInitialPermits() { - return initialPermits; - } - - /** - * Sets the initial number of permits. The initial number of permits can be 0; meaning that there is no permit. - * It can also be a negative number, meaning that there is a shortage of permits. - * - * @param initialPermits the initial number of permits - * @return the updated SemaphoreConfig - */ - public SemaphoreConfig setInitialPermits(int initialPermits) { - this.initialPermits = initialPermits; - return this; - } - - /** - * Returns the number of synchronous backups. - * - * @return the number of synchronous backups - * @see #setBackupCount(int) - */ - public int getBackupCount() { - return backupCount; - } - - /** - * Sets the number of synchronous backups. - * - * @param backupCount the number of synchronous backups to set - * @return the updated SemaphoreConfig - * @throws IllegalArgumentException if backupCount smaller than 0, - * or larger than the maximum number of backup - * or the sum of the backups and async backups is larger - * than the maximum number of backups - * @see #setAsyncBackupCount(int) - * @see #getBackupCount() - */ - public SemaphoreConfig setBackupCount(int backupCount) { - this.backupCount = checkBackupCount(backupCount, asyncBackupCount); - return this; - } - - /** - * Returns the number of asynchronous backups. - * - * @return the number of asynchronous backups - * @see #setAsyncBackupCount(int) - */ - public int getAsyncBackupCount() { - return asyncBackupCount; - } - - /** - * Sets the number of asynchronous backups. 0 means no backups. - * - * @param asyncBackupCount the number of asynchronous synchronous backups to set - * @return the updated SemaphoreConfig - * @throws IllegalArgumentException if asyncBackupCount smaller than 0, - * or larger than the maximum number of backup - * or the sum of the backups and async backups is larger than the maximum - * number of backups - * @see #setBackupCount(int) - * @see #getAsyncBackupCount() - */ - public SemaphoreConfig setAsyncBackupCount(int asyncBackupCount) { - this.asyncBackupCount = checkAsyncBackupCount(backupCount, asyncBackupCount); - return this; - } - - /** - * Returns the total number of backups (synchronous plus asynchronous); - * the returned value will always equal or bigger than 0. - * - * @return the total number of backups (synchronous plus asynchronous) - */ - public int getTotalBackupCount() { - return asyncBackupCount + backupCount; - } - - public String getSplitBrainProtectionName() { - return splitBrainProtectionName; - } - - public SemaphoreConfig setSplitBrainProtectionName(String splitBrainProtectionName) { - this.splitBrainProtectionName = splitBrainProtectionName; - return this; - } - - @Override - public String toString() { - return "SemaphoreConfig{" - + "name='" + name + '\'' - + ", initialPermits=" + initialPermits - + ", backupCount=" + backupCount - + ", asyncBackupCount=" + asyncBackupCount - + ", splitBrainProtectionName=" + splitBrainProtectionName - + '}'; - } - - @Override - public int getFactoryId() { - return ConfigDataSerializerHook.F_ID; - } - - @Override - public int getClassId() { - return ConfigDataSerializerHook.SEMAPHORE_CONFIG; - } - - @Override - public void writeData(ObjectDataOutput out) throws IOException { - out.writeUTF(name); - out.writeInt(initialPermits); - out.writeInt(backupCount); - out.writeInt(asyncBackupCount); - out.writeUTF(splitBrainProtectionName); - } - - @Override - public void readData(ObjectDataInput in) throws IOException { - name = in.readUTF(); - initialPermits = in.readInt(); - backupCount = in.readInt(); - asyncBackupCount = in.readInt(); - splitBrainProtectionName = in.readUTF(); - } - - @SuppressWarnings("checkstyle:npathcomplexity") - @Override - public final boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof SemaphoreConfig)) { - return false; - } - - SemaphoreConfig that = (SemaphoreConfig) o; - - if (initialPermits != that.initialPermits) { - return false; - } - if (backupCount != that.backupCount) { - return false; - } - if (asyncBackupCount != that.asyncBackupCount) { - return false; - } - if (splitBrainProtectionName != null ? !splitBrainProtectionName.equals(that.splitBrainProtectionName) - : that.splitBrainProtectionName != null) { - return false; - } - return name != null ? name.equals(that.name) : that.name == null; - } - - @Override - public final int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + initialPermits; - result = 31 * result + backupCount; - result = 31 * result + asyncBackupCount; - result = 31 * result + (splitBrainProtectionName != null ? splitBrainProtectionName.hashCode() : 0); - return result; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/config/SemaphoreConfigReadOnly.java b/hazelcast/src/main/java/com/hazelcast/config/SemaphoreConfigReadOnly.java deleted file mode 100644 index 5e11d936d3d51..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/config/SemaphoreConfigReadOnly.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.config; - -/** - * Contains configuration for Semaphore(read only) - * - * @deprecated this class will be removed in 4.0; it is meant for internal usage only. - */ -public class SemaphoreConfigReadOnly extends SemaphoreConfig { - - public SemaphoreConfigReadOnly(SemaphoreConfig config) { - super(config); - } - - @Override - public SemaphoreConfig setName(String name) { - throw new UnsupportedOperationException("This config is read-only semaphore: " + getName()); - } - - @Override - public SemaphoreConfig setInitialPermits(int initialPermits) { - throw new UnsupportedOperationException("This config is read-only semaphore: " + getName()); - } - - @Override - public SemaphoreConfig setBackupCount(int backupCount) { - throw new UnsupportedOperationException("This config is read-only semaphore: " + getName()); - } - - @Override - public SemaphoreConfig setAsyncBackupCount(int asyncBackupCount) { - throw new UnsupportedOperationException("This config is read-only semaphore: " + getName()); - } - - @Override - public SemaphoreConfig setSplitBrainProtectionName(String splitBrainProtectionName) { - throw new UnsupportedOperationException("This config is read-only semaphore: " + getName()); - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/config/YamlMemberDomConfigProcessor.java b/hazelcast/src/main/java/com/hazelcast/config/YamlMemberDomConfigProcessor.java index 75771f3292891..8da416e53a310 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/YamlMemberDomConfigProcessor.java +++ b/hazelcast/src/main/java/com/hazelcast/config/YamlMemberDomConfigProcessor.java @@ -16,7 +16,7 @@ package com.hazelcast.config; -import com.hazelcast.config.cp.CPSemaphoreConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.instance.ProtocolType; @@ -225,15 +225,6 @@ protected void handlePort(Node node, Config config) { } } - @Override - protected void handleSemaphore(Node node) { - for (Node semaphoreNode : childElements(node)) { - SemaphoreConfig sConfig = new SemaphoreConfig(); - sConfig.setName(semaphoreNode.getNodeName()); - handleSemaphoreNode(semaphoreNode, sConfig); - } - } - @Override protected void handleQueue(Node node) { for (Node queueNode : childElements(node)) { @@ -878,18 +869,18 @@ protected void handleWanEndpointConfig(Node node) throws Exception { } @Override - void handleCPSemaphores(CPSubsystemConfig cpSubsystemConfig, Node node) { + void handleSemaphores(CPSubsystemConfig cpSubsystemConfig, Node node) { for (Node child : childElements(node)) { - CPSemaphoreConfig cpSemaphoreConfig = new CPSemaphoreConfig(); - cpSemaphoreConfig.setName(child.getNodeName()); + SemaphoreConfig semaphoreConfig = new SemaphoreConfig(); + semaphoreConfig.setName(child.getNodeName()); for (Node subChild : childElements(child)) { String nodeName = cleanNodeName(subChild); String value = getTextContent(subChild).trim(); if ("jdk-compatible".equals(nodeName)) { - cpSemaphoreConfig.setJDKCompatible(Boolean.parseBoolean(value)); + semaphoreConfig.setJDKCompatible(Boolean.parseBoolean(value)); } } - cpSubsystemConfig.addSemaphoreConfig(cpSemaphoreConfig); + cpSubsystemConfig.addSemaphoreConfig(semaphoreConfig); } } diff --git a/hazelcast/src/main/java/com/hazelcast/config/cp/CPSubsystemConfig.java b/hazelcast/src/main/java/com/hazelcast/config/cp/CPSubsystemConfig.java index 900e23d0b3e8c..07ad4595885f5 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/cp/CPSubsystemConfig.java +++ b/hazelcast/src/main/java/com/hazelcast/config/cp/CPSubsystemConfig.java @@ -247,7 +247,7 @@ public class CPSubsystemConfig { /** * Configurations for CP {@link ISemaphore} instances */ - private final Map semaphoreConfigs = new ConcurrentHashMap(); + private final Map semaphoreConfigs = new ConcurrentHashMap(); /** * Configurations for {@link FencedLock} instances @@ -267,8 +267,8 @@ public CPSubsystemConfig(CPSubsystemConfig config) { this.sessionHeartbeatIntervalSeconds = config.sessionHeartbeatIntervalSeconds; this.failOnIndeterminateOperationState = config.failOnIndeterminateOperationState; this.missingCPMemberAutoRemovalSeconds = config.missingCPMemberAutoRemovalSeconds; - for (CPSemaphoreConfig semaphoreConfig : config.semaphoreConfigs.values()) { - this.semaphoreConfigs.put(semaphoreConfig.getName(), new CPSemaphoreConfig(semaphoreConfig)); + for (SemaphoreConfig semaphoreConfig : config.semaphoreConfigs.values()) { + this.semaphoreConfigs.put(semaphoreConfig.getName(), new SemaphoreConfig(semaphoreConfig)); } for (FencedLockConfig lockConfig : config.lockConfigs.values()) { this.lockConfigs.put(lockConfig.getName(), new FencedLockConfig(lockConfig)); @@ -449,7 +449,7 @@ public CPSubsystemConfig setRaftAlgorithmConfig(RaftAlgorithmConfig raftAlgorith * * @return the map of CP {@link ISemaphore} configurations */ - public Map getSemaphoreConfigs() { + public Map getSemaphoreConfigs() { return semaphoreConfigs; } @@ -463,7 +463,7 @@ public Map getSemaphoreConfigs() { * @param name name of the CP {@link ISemaphore} * @return the CP {@link ISemaphore} configuration */ - public CPSemaphoreConfig findSemaphoreConfig(String name) { + public SemaphoreConfig findSemaphoreConfig(String name) { return lookupByPattern(configPatternMatcher, semaphoreConfigs, getBaseName(name)); } @@ -472,11 +472,11 @@ public CPSemaphoreConfig findSemaphoreConfig(String name) { * {@link ISemaphore} could optionally contain a {@link CPGroup} name, * like "mySemaphore@group1". * - * @param cpSemaphoreConfig the CP {@link ISemaphore} configuration + * @param semaphoreConfig the CP {@link ISemaphore} configuration * @return this config instance */ - public CPSubsystemConfig addSemaphoreConfig(CPSemaphoreConfig cpSemaphoreConfig) { - semaphoreConfigs.put(cpSemaphoreConfig.getName(), cpSemaphoreConfig); + public CPSubsystemConfig addSemaphoreConfig(SemaphoreConfig semaphoreConfig) { + semaphoreConfigs.put(semaphoreConfig.getName(), semaphoreConfig); return this; } @@ -485,13 +485,13 @@ public CPSubsystemConfig addSemaphoreConfig(CPSemaphoreConfig cpSemaphoreConfig) * mapped by config name. Names could optionally contain * a {@link CPGroup} name, such as "mySemaphore@group1". * - * @param cpSemaphoreConfigs the CP {@link ISemaphore} config map to set + * @param semaphoreConfigs the CP {@link ISemaphore} config map to set * @return this config instance */ - public CPSubsystemConfig setSemaphoreConfigs(Map cpSemaphoreConfigs) { + public CPSubsystemConfig setSemaphoreConfigs(Map semaphoreConfigs) { this.semaphoreConfigs.clear(); - this.semaphoreConfigs.putAll(cpSemaphoreConfigs); - for (Entry entry : this.semaphoreConfigs.entrySet()) { + this.semaphoreConfigs.putAll(semaphoreConfigs); + for (Entry entry : this.semaphoreConfigs.entrySet()) { entry.getValue().setName(entry.getKey()); } return this; diff --git a/hazelcast/src/main/java/com/hazelcast/config/cp/CPSemaphoreConfig.java b/hazelcast/src/main/java/com/hazelcast/config/cp/SemaphoreConfig.java similarity index 87% rename from hazelcast/src/main/java/com/hazelcast/config/cp/CPSemaphoreConfig.java rename to hazelcast/src/main/java/com/hazelcast/config/cp/SemaphoreConfig.java index 161b5b5a2251f..dd66d817596f2 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/cp/CPSemaphoreConfig.java +++ b/hazelcast/src/main/java/com/hazelcast/config/cp/SemaphoreConfig.java @@ -24,7 +24,7 @@ /** * Contains configuration options for the CP {@link ISemaphore} */ -public class CPSemaphoreConfig { +public class SemaphoreConfig { /** * Default value for JDK compatibility mode of the CP {@link ISemaphore} @@ -57,20 +57,20 @@ public class CPSemaphoreConfig { */ private boolean jdkCompatible = DEFAULT_SEMAPHORE_JDK_COMPATIBILITY; - public CPSemaphoreConfig() { + public SemaphoreConfig() { super(); } - public CPSemaphoreConfig(String name) { + public SemaphoreConfig(String name) { this.name = name; } - public CPSemaphoreConfig(String name, boolean jdkCompatible) { + public SemaphoreConfig(String name, boolean jdkCompatible) { this.name = name; this.jdkCompatible = jdkCompatible; } - CPSemaphoreConfig(CPSemaphoreConfig config) { + SemaphoreConfig(SemaphoreConfig config) { this.name = config.name; this.jdkCompatible = config.jdkCompatible; } @@ -85,7 +85,7 @@ public String getName() { /** * Sets name of the semaphore */ - public CPSemaphoreConfig setName(String name) { + public SemaphoreConfig setName(String name) { this.name = name; return this; } @@ -101,13 +101,13 @@ public boolean isJDKCompatible() { /** * Sets JDK compatibility mode of the CP {@link ISemaphore} */ - public CPSemaphoreConfig setJDKCompatible(boolean jdkCompatible) { + public SemaphoreConfig setJDKCompatible(boolean jdkCompatible) { this.jdkCompatible = jdkCompatible; return this; } @Override public String toString() { - return "CPSemaphoreConfig{" + "name='" + name + ", jdkCompatible=" + jdkCompatible + '\'' + '}'; + return "SemaphoreConfig{" + "name='" + name + ", jdkCompatible=" + jdkCompatible + '\'' + '}'; } } diff --git a/hazelcast/src/main/java/com/hazelcast/core/HazelcastInstance.java b/hazelcast/src/main/java/com/hazelcast/core/HazelcastInstance.java index 36c815770daf6..ec540f93ea9ef 100644 --- a/hazelcast/src/main/java/com/hazelcast/core/HazelcastInstance.java +++ b/hazelcast/src/main/java/com/hazelcast/core/HazelcastInstance.java @@ -29,7 +29,6 @@ import com.hazelcast.cp.CPSubsystem; import com.hazelcast.cp.IAtomicLong; import com.hazelcast.cp.IAtomicReference; -import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.lock.ILock; import com.hazelcast.crdt.pncounter.PNCounter; import com.hazelcast.durableexecutor.DurableExecutorService; @@ -328,19 +327,6 @@ public interface HazelcastInstance { @Deprecated IAtomicReference getAtomicReference(String name); - /** - * Creates or returns a cluster-wide semaphore. Hazelcast {@link ISemaphore} is distributed - * implementation of java.util.concurrent.Semaphore. - * - * @param name name of the {@link ISemaphore} proxy - * @return {@link ISemaphore} proxy for the given name - * @deprecated This implementation may lose strong consistency in case of network failures - * or server failures. Please use {@link CPSubsystem#getSemaphore(String)} instead. - * This method will be removed in Hazelcast 4.0. - */ - @Deprecated - ISemaphore getSemaphore(String name); - /** * Returns all {@link DistributedObject}s, that is all maps, queues, * topics, locks etc. diff --git a/hazelcast/src/main/java/com/hazelcast/cp/CPSubsystem.java b/hazelcast/src/main/java/com/hazelcast/cp/CPSubsystem.java index 3ec63c1a20a1e..3eb6cf11946a1 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/CPSubsystem.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/CPSubsystem.java @@ -16,7 +16,7 @@ package com.hazelcast.cp; -import com.hazelcast.config.cp.CPSemaphoreConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.core.DistributedObject; @@ -255,7 +255,7 @@ public interface CPSubsystem { * Each call of this method performs a commit to the Metadata CP * group. Hence, callers should cache the returned proxy. * - * @see CPSemaphoreConfig + * @see SemaphoreConfig * * @param name name of the {@link ISemaphore} proxy * @return {@link ISemaphore} proxy for the given name diff --git a/hazelcast/src/main/java/com/hazelcast/cp/ICountDownLatch.java b/hazelcast/src/main/java/com/hazelcast/cp/ICountDownLatch.java index 6f686c4488a66..7c0944d36d04c 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/ICountDownLatch.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/ICountDownLatch.java @@ -32,7 +32,7 @@ * {@link java.util.concurrent.CountDownLatch java.util.concurrent.CountDownLatch}: *

    *
  1. - * the ICountDownLatch count can be reset using {@link #trySetCount(int)} after + * ICountDownLatch count can be reset using {@link #trySetCount(int)} after * a countdown has finished but not during an active count. This allows * the same latch instance to be reused. *
  2. diff --git a/hazelcast/src/main/java/com/hazelcast/cp/ISemaphore.java b/hazelcast/src/main/java/com/hazelcast/cp/ISemaphore.java index cdcbe55f6adb5..0a4723564ab14 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/ISemaphore.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/ISemaphore.java @@ -16,9 +16,8 @@ package com.hazelcast.cp; -import com.hazelcast.config.SplitBrainProtectionConfig; -import com.hazelcast.config.cp.CPSemaphoreConfig; import com.hazelcast.config.cp.CPSubsystemConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.core.DistributedObject; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.cp.lock.FencedLock; @@ -57,33 +56,13 @@ * Correct usage of a semaphore is established by programming convention * in the application. *

    - * As of version 3.12, Hazelcast offers 2 different {@link ISemaphore} impls. - * Behaviour of {@link ISemaphore} under failure scenarios, including network - * partitions, depends on the impl. The first impl is the one accessed via - * {@link HazelcastInstance#getSemaphore(String)}. It works on top of - * Hazelcast's async replication algorithm and does not guarantee - * linearizability during failures. During a split-brain scenario, this impl - * loses its atomicity. It is possible for the same {@link ISemaphore} instance - * to exist in each side of the network partition and therefore the permit - * counters can diverge. When the cluster heals, Hazelcast will choose one of - * the {@link ISemaphore} instances. By default, it is selected from the - * largest partitioned cluster (by number of members). If the cluster sizes are - * all equal, then a random {@link ISemaphore} instance will be chosen. - *

    - * This {@link ISemaphore} impl also supports split brain protection - * {@link SplitBrainProtectionConfig} in cluster versions 3.10 and higher. - * However, Hazelcast split brain protections do not guarantee strong consistency - * under failure scenarios. - *

    - * The second impl is a new one introduced with the {@link CPSubsystem} in - * version 3.12. It is accessed via {@link CPSubsystem#getSemaphore(String)}. - * It has a major difference to the old implementation, that is, it works on - * top of the Raft consensus algorithm. It offers linearizability during crash + * {@link ISemaphore} is accessed via {@link CPSubsystem#getSemaphore(String)}. + * It works on top of the Raft consensus algorithm. It offers linearizability during crash * failures and network partitions. It is CP with respect to the CAP principle. * If a network partition occurs, it remains available on at most one side of * the partition. *

    - * The new CP impl has 2 variations: + * It has 2 variations: *

      *
    • * The default impl accessed via {@link CPSubsystem} is session-aware. In this @@ -99,7 +78,7 @@ * HazelcastInstance, but not different instances of HazelcastInstance. This * behaviour is not compatible with {@link Semaphore#release()}. You can use * the session-aware CP {@link ISemaphore} impl by disabling JDK compatibility - * via {@link CPSemaphoreConfig#setJDKCompatible(boolean)}. Although + * via {@link SemaphoreConfig#setJDKCompatible(boolean)}. Although * the session-aware impl has a minor difference to the JDK Semaphore, we think * it is a better fit for distributed environments because of its safe * auto-cleanup mechanism for acquired permits. Please see @@ -114,7 +93,7 @@ * server or a client fails while holding some permits, they will not be * automatically released. You can use the sessionless CP {@link ISemaphore} * impl by enabling JDK compatibility via - * {@link CPSemaphoreConfig#setJDKCompatible(boolean)}. + * {@link SemaphoreConfig#setJDKCompatible(boolean)}. *
    • *
    *

    @@ -258,13 +237,13 @@ public interface ISemaphore extends DistributedObject { * of them will unblock by acquiring the permit released by this call. *

    * If the underlying {@link ISemaphore} impl is the non-JDK compatible - * CP impl that is configured via {@link CPSemaphoreConfig} and fetched + * CP impl that is configured via {@link SemaphoreConfig} and fetched * via {@link CPSubsystem}, then a thread can only release a permit which * it has acquired before. In other words, a thread cannot release a permit * without acquiring it first. *

    * Otherwise, which means the underlying impl is either the JDK compatible - * CP impl configured via {@link CPSemaphoreConfig} and fetched + * CP impl configured via {@link SemaphoreConfig} and fetched * via {@link CPSubsystem}, or it is the old impl fetched via * {@link HazelcastInstance#getSemaphore(String)}, there is no requirement * that a thread that releases a permit must have acquired that permit by @@ -280,13 +259,13 @@ public interface ISemaphore extends DistributedObject { * blocked for acquiring permits, they will be notified. *

    * If the underlying {@link ISemaphore} impl is the non-JDK compatible - * CP impl that is configured via {@link CPSemaphoreConfig} and fetched + * CP impl that is configured via {@link SemaphoreConfig} and fetched * via {@link CPSubsystem}, then a thread can only release a permit which * it has acquired before. In other words, a thread cannot release a permit * without acquiring it first. *

    * Otherwise, which means the underlying impl is either the JDK compatible - * CP impl configured via {@link CPSemaphoreConfig} and fetched + * CP impl configured via {@link SemaphoreConfig} and fetched * via {@link CPSubsystem}, or it is the old impl fetched via * {@link HazelcastInstance#getSemaphore(String)}, there is no requirement * that a thread that releases a permit must have acquired that permit by diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/CPSubsystemImpl.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/CPSubsystemImpl.java index 72e34b86b3c9b..bc833dffd9cd9 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/CPSubsystemImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/CPSubsystemImpl.java @@ -29,7 +29,7 @@ import com.hazelcast.cp.internal.datastructures.atomicref.RaftAtomicRefService; import com.hazelcast.cp.internal.datastructures.countdownlatch.CountDownLatchService; import com.hazelcast.cp.internal.datastructures.lock.RaftLockService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.spi.RaftRemoteService; import com.hazelcast.cp.internal.session.RaftSessionService; import com.hazelcast.cp.lock.FencedLock; @@ -87,7 +87,7 @@ public FencedLock getLock(String name) { @Override public ISemaphore getSemaphore(String name) { checkNotNull(name, "Retrieving a semaphore instance with a null name is not allowed!"); - return createProxy(RaftSemaphoreService.SERVICE_NAME, name); + return createProxy(SemaphoreService.SERVICE_NAME, name); } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/RaftDataServiceDescriptorProvider.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/RaftDataServiceDescriptorProvider.java index ede6dea13b408..4d5e949258714 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/RaftDataServiceDescriptorProvider.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/RaftDataServiceDescriptorProvider.java @@ -21,7 +21,7 @@ import com.hazelcast.cp.internal.datastructures.atomiclong.RaftAtomicLongService; import com.hazelcast.cp.internal.datastructures.atomicref.RaftAtomicRefService; import com.hazelcast.cp.internal.datastructures.lock.RaftLockService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.spi.impl.NodeEngine; import com.hazelcast.spi.impl.servicemanager.ServiceDescriptor; import com.hazelcast.spi.impl.servicemanager.ServiceDescriptorProvider; @@ -38,7 +38,7 @@ public ServiceDescriptor[] createServiceDescriptors() { new RaftLockServiceDescriptor(), new RaftSessionManagerServiceDescriptor(), new RaftAtomicRefServiceDescriptor(), - new RaftSemaphoreServiceDescriptor(), + new SemaphoreServiceDescriptor(), new CountDownLatcherviceDescriptor(), }; } @@ -91,15 +91,15 @@ public Object getService(NodeEngine nodeEngine) { } } - private static class RaftSemaphoreServiceDescriptor implements ServiceDescriptor { + private static class SemaphoreServiceDescriptor implements ServiceDescriptor { @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override public Object getService(NodeEngine nodeEngine) { - return new RaftSemaphoreService(nodeEngine); + return new SemaphoreService(nodeEngine); } } diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/AcquireInvocationKey.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/AcquireInvocationKey.java index 0a6a3a2e1fb71..eb06bfcbd988d 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/AcquireInvocationKey.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/AcquireInvocationKey.java @@ -72,12 +72,12 @@ boolean isDifferentInvocationOf(SemaphoreEndpoint endpoint, UUID invocationUid) @Override public int getFactoryId() { - return RaftSemaphoreDataSerializerHook.F_ID; + return SemaphoreDataSerializerHook.F_ID; } @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.ACQUIRE_INVOCATION_KEY; + return SemaphoreDataSerializerHook.ACQUIRE_INVOCATION_KEY; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/Semaphore.java similarity index 97% rename from hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java rename to hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/Semaphore.java index f4c33287eab55..7bad08569b1bf 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/Semaphore.java @@ -48,16 +48,16 @@ * State-machine implementation of the Raft-based semaphore. * Supports both sessionless and session-aware semaphore proxies. */ -public class RaftSemaphore extends BlockingResource implements IdentifiedDataSerializable { +public class Semaphore extends BlockingResource implements IdentifiedDataSerializable { private boolean initialized; private int available; private final Long2ObjectHashMap sessionStates = new Long2ObjectHashMap<>(); - RaftSemaphore() { + Semaphore() { } - RaftSemaphore(CPGroupId groupId, String name) { + Semaphore(CPGroupId groupId, String name) { super(groupId, name); } @@ -182,8 +182,8 @@ ReleaseResult release(SemaphoreEndpoint endpoint, UUID invocationUid, int permit return ReleaseResult.successful(acquired, cancelled); } - RaftSemaphore cloneForSnapshot() { - RaftSemaphore clone = new RaftSemaphore(); + Semaphore cloneForSnapshot() { + Semaphore clone = new Semaphore(); cloneForSnapshot(clone); clone.initialized = this.initialized; clone.available = this.available; @@ -327,12 +327,12 @@ protected Collection getActivelyAttachedSessions() { @Override public int getFactoryId() { - return RaftSemaphoreDataSerializerHook.F_ID; + return SemaphoreDataSerializerHook.F_ID; } @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.RAFT_SEMAPHORE; + return SemaphoreDataSerializerHook.RAFT_SEMAPHORE; } @Override @@ -380,7 +380,7 @@ public void readData(ObjectDataInput in) throws IOException { @Override public String toString() { - return "RaftSemaphore{" + internalToString() + ", initialized=" + initialized + return "Semaphore{" + internalToString() + ", initialized=" + initialized + ", available=" + available + ", sessionStates=" + sessionStates + '}'; } diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreDataSerializerHook.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreDataSerializerHook.java similarity index 94% rename from hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreDataSerializerHook.java rename to hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreDataSerializerHook.java index c1e993432fad2..66a857d8ae76a 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreDataSerializerHook.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreDataSerializerHook.java @@ -27,7 +27,7 @@ import com.hazelcast.nio.serialization.DataSerializableFactory; @SuppressWarnings("checkstyle:declarationorder") -public class RaftSemaphoreDataSerializerHook implements DataSerializerHook { +public class SemaphoreDataSerializerHook implements DataSerializerHook { private static final int DS_FACTORY_ID = -1013; private static final String DS_FACTORY = "hazelcast.serialization.ds.raft.sema"; @@ -54,9 +54,9 @@ public DataSerializableFactory createFactory() { return typeId -> { switch (typeId) { case RAFT_SEMAPHORE_REGISTRY: - return new RaftSemaphoreRegistry(); + return new SemaphoreRegistry(); case RAFT_SEMAPHORE: - return new RaftSemaphore(); + return new Semaphore(); case ACQUIRE_INVOCATION_KEY: return new AcquireInvocationKey(); case SEMAPHORE_ENDPOINT: diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreEndpoint.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreEndpoint.java index bd6df3b357d6a..55d2cd6aa6471 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreEndpoint.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreEndpoint.java @@ -52,12 +52,12 @@ public long threadId() { @Override public int getFactoryId() { - return RaftSemaphoreDataSerializerHook.F_ID; + return SemaphoreDataSerializerHook.F_ID; } @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.SEMAPHORE_ENDPOINT; + return SemaphoreDataSerializerHook.SEMAPHORE_ENDPOINT; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreRegistry.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreRegistry.java similarity index 79% rename from hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreRegistry.java rename to hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreRegistry.java index 5a57e4ef7ff63..e5460a1402532 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreRegistry.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreRegistry.java @@ -17,8 +17,8 @@ package com.hazelcast.cp.internal.datastructures.semaphore; import com.hazelcast.cp.CPGroupId; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore.AcquireResult; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore.ReleaseResult; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore.AcquireResult; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore.ReleaseResult; import com.hazelcast.cp.internal.datastructures.spi.blocking.ResourceRegistry; import com.hazelcast.nio.serialization.IdentifiedDataSerializable; @@ -27,29 +27,29 @@ import java.util.UUID; /** - * Contains {@link RaftSemaphore} resources and manages wait timeouts + * Contains {@link Semaphore} resources and manages wait timeouts * based on acquire / release requests */ -public class RaftSemaphoreRegistry extends ResourceRegistry +public class SemaphoreRegistry extends ResourceRegistry implements IdentifiedDataSerializable { - RaftSemaphoreRegistry() { + SemaphoreRegistry() { } - RaftSemaphoreRegistry(CPGroupId groupId) { + SemaphoreRegistry(CPGroupId groupId) { super(groupId); } @Override - protected RaftSemaphore createNewResource(CPGroupId groupId, String name) { - return new RaftSemaphore(groupId, name); + protected Semaphore createNewResource(CPGroupId groupId, String name) { + return new Semaphore(groupId, name); } @Override - protected RaftSemaphoreRegistry cloneForSnapshot() { - RaftSemaphoreRegistry clone = new RaftSemaphoreRegistry(); + protected SemaphoreRegistry cloneForSnapshot() { + SemaphoreRegistry clone = new SemaphoreRegistry(); clone.groupId = this.groupId; - for (Entry e : this.resources.entrySet()) { + for (Entry e : this.resources.entrySet()) { clone.resources.put(e.getKey(), e.getValue().cloneForSnapshot()); } clone.destroyedNames.addAll(this.destroyedNames); @@ -69,7 +69,7 @@ Collection init(String name, int permits) { } int availablePermits(String name) { - RaftSemaphore semaphore = getResourceOrNull(name); + Semaphore semaphore = getResourceOrNull(name); return semaphore != null ? semaphore.getAvailable() : 0; } @@ -124,11 +124,11 @@ ReleaseResult changePermits(String name, SemaphoreEndpoint endpoint, UUID invoca @Override public int getFactoryId() { - return RaftSemaphoreDataSerializerHook.F_ID; + return SemaphoreDataSerializerHook.F_ID; } @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.RAFT_SEMAPHORE_REGISTRY; + return SemaphoreDataSerializerHook.RAFT_SEMAPHORE_REGISTRY; } } diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreService.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreService.java similarity index 87% rename from hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreService.java rename to hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreService.java index fb2972765e978..33bc72598b9d0 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreService.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/SemaphoreService.java @@ -16,15 +16,15 @@ package com.hazelcast.cp.internal.datastructures.semaphore; -import com.hazelcast.config.cp.CPSemaphoreConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.CPGroupId; import com.hazelcast.cp.internal.RaftGroupId; import com.hazelcast.cp.internal.datastructures.exception.WaitKeyCancelledException; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore.AcquireResult; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore.ReleaseResult; -import com.hazelcast.cp.internal.datastructures.semaphore.proxy.RaftSessionAwareSemaphoreProxy; -import com.hazelcast.cp.internal.datastructures.semaphore.proxy.RaftSessionlessSemaphoreProxy; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore.AcquireResult; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore.ReleaseResult; +import com.hazelcast.cp.internal.datastructures.semaphore.proxy.SessionAwareSemaphoreProxy; +import com.hazelcast.cp.internal.datastructures.semaphore.proxy.SessionlessSemaphoreProxy; import com.hazelcast.cp.internal.datastructures.spi.blocking.AbstractBlockingService; import com.hazelcast.spi.impl.NodeEngine; @@ -38,18 +38,18 @@ /** * Contains Raft-based semaphore instances */ -public class RaftSemaphoreService extends AbstractBlockingService { +public class SemaphoreService extends AbstractBlockingService { /** * Name of the service */ public static final String SERVICE_NAME = "hz:raft:semaphoreService"; - public RaftSemaphoreService(NodeEngine nodeEngine) { + public SemaphoreService(NodeEngine nodeEngine) { super(nodeEngine); } - private CPSemaphoreConfig getConfig(String name) { + private SemaphoreConfig getConfig(String name) { return nodeEngine.getConfig().getCPSubsystemConfig().findSemaphoreConfig(name); } @@ -65,7 +65,7 @@ public boolean initSemaphore(CPGroupId groupId, String name, int permits) { } public int availablePermits(CPGroupId groupId, String name) { - RaftSemaphoreRegistry registry = getRegistryOrNull(groupId); + SemaphoreRegistry registry = getRegistryOrNull(groupId); return registry != null ? registry.availablePermits(name) : 0; } @@ -155,8 +155,8 @@ private void notifyCancelledWaitKeys(CPGroupId groupId, String name, Collection< } @Override - protected RaftSemaphoreRegistry createNewRegistry(CPGroupId groupId) { - return new RaftSemaphoreRegistry(groupId); + protected SemaphoreRegistry createNewRegistry(CPGroupId groupId) { + return new SemaphoreRegistry(groupId); } @Override @@ -175,10 +175,10 @@ public ISemaphore createProxy(String proxyName) { proxyName = withoutDefaultGroupName(proxyName); RaftGroupId groupId = raftService.createRaftGroupForProxy(proxyName); String objectName = getObjectNameForProxy(proxyName); - CPSemaphoreConfig config = getConfig(proxyName); + SemaphoreConfig config = getConfig(proxyName); return config != null && config.isJDKCompatible() - ? new RaftSessionlessSemaphoreProxy(nodeEngine, groupId, proxyName, objectName) - : new RaftSessionAwareSemaphoreProxy(nodeEngine, groupId, proxyName, objectName); + ? new SessionlessSemaphoreProxy(nodeEngine, groupId, proxyName, objectName) + : new SessionAwareSemaphoreProxy(nodeEngine, groupId, proxyName, objectName); } catch (Exception e) { throw rethrow(e); } diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/AcquirePermitsMessageTask.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/AcquirePermitsMessageTask.java index 0911fce41ab84..15f4febe86fdc 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/AcquirePermitsMessageTask.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/AcquirePermitsMessageTask.java @@ -17,12 +17,12 @@ package com.hazelcast.cp.internal.datastructures.semaphore.client; import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreAcquireCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreAcquireCodec; import com.hazelcast.client.impl.protocol.task.AbstractMessageTask; import com.hazelcast.core.ExecutionCallback; import com.hazelcast.cp.internal.RaftOp; import com.hazelcast.cp.internal.RaftService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.operation.AcquirePermitsOp; import com.hazelcast.instance.impl.Node; import com.hazelcast.nio.Connection; @@ -35,7 +35,7 @@ /** * Client message task for {@link AcquirePermitsOp} */ -public class AcquirePermitsMessageTask extends AbstractMessageTask +public class AcquirePermitsMessageTask extends AbstractMessageTask implements ExecutionCallback { public AcquirePermitsMessageTask(ClientMessage clientMessage, Node node, Connection connection) { @@ -51,18 +51,18 @@ protected void processMessage() { } @Override - protected CPSemaphoreAcquireCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return CPSemaphoreAcquireCodec.decodeRequest(clientMessage); + protected SemaphoreAcquireCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { + return SemaphoreAcquireCodec.decodeRequest(clientMessage); } @Override protected ClientMessage encodeResponse(Object response) { - return CPSemaphoreAcquireCodec.encodeResponse((Boolean) response); + return SemaphoreAcquireCodec.encodeResponse((Boolean) response); } @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/AvailablePermitsMessageTask.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/AvailablePermitsMessageTask.java index 1799bd6f1be65..46c9802949130 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/AvailablePermitsMessageTask.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/AvailablePermitsMessageTask.java @@ -17,11 +17,11 @@ package com.hazelcast.cp.internal.datastructures.semaphore.client; import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreAvailablePermitsCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreAvailablePermitsCodec; import com.hazelcast.client.impl.protocol.task.AbstractMessageTask; import com.hazelcast.core.ExecutionCallback; import com.hazelcast.cp.internal.RaftService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.operation.AvailablePermitsOp; import com.hazelcast.instance.impl.Node; import com.hazelcast.nio.Connection; @@ -35,7 +35,7 @@ /** * Client message task for {@link AvailablePermitsOp} */ -public class AvailablePermitsMessageTask extends AbstractMessageTask +public class AvailablePermitsMessageTask extends AbstractMessageTask implements ExecutionCallback { public AvailablePermitsMessageTask(ClientMessage clientMessage, Node node, Connection connection) { @@ -51,18 +51,18 @@ protected void processMessage() { } @Override - protected CPSemaphoreAvailablePermitsCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return CPSemaphoreAvailablePermitsCodec.decodeRequest(clientMessage); + protected SemaphoreAvailablePermitsCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { + return SemaphoreAvailablePermitsCodec.decodeRequest(clientMessage); } @Override protected ClientMessage encodeResponse(Object response) { - return CPSemaphoreAvailablePermitsCodec.encodeResponse((Integer) response); + return SemaphoreAvailablePermitsCodec.encodeResponse((Integer) response); } @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/ChangePermitsMessageTask.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/ChangePermitsMessageTask.java index c106e2910a16a..279b5b34f7060 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/ChangePermitsMessageTask.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/ChangePermitsMessageTask.java @@ -17,12 +17,12 @@ package com.hazelcast.cp.internal.datastructures.semaphore.client; import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreChangeCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreChangeCodec; import com.hazelcast.client.impl.protocol.task.AbstractMessageTask; import com.hazelcast.core.ExecutionCallback; import com.hazelcast.cp.internal.RaftOp; import com.hazelcast.cp.internal.RaftService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp; import com.hazelcast.instance.impl.Node; import com.hazelcast.nio.Connection; @@ -36,7 +36,7 @@ /** * Client message task for {@link ChangePermitsOp} */ -public class ChangePermitsMessageTask extends AbstractMessageTask +public class ChangePermitsMessageTask extends AbstractMessageTask implements ExecutionCallback { public ChangePermitsMessageTask(ClientMessage clientMessage, Node node, Connection connection) { @@ -52,18 +52,18 @@ protected void processMessage() { } @Override - protected CPSemaphoreChangeCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return CPSemaphoreChangeCodec.decodeRequest(clientMessage); + protected SemaphoreChangeCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { + return SemaphoreChangeCodec.decodeRequest(clientMessage); } @Override protected ClientMessage encodeResponse(Object response) { - return CPSemaphoreChangeCodec.encodeResponse((Boolean) response); + return SemaphoreChangeCodec.encodeResponse((Boolean) response); } @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/DrainPermitsMessageTask.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/DrainPermitsMessageTask.java index ac6950ffeb910..2cac1da9fbed1 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/DrainPermitsMessageTask.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/DrainPermitsMessageTask.java @@ -17,12 +17,12 @@ package com.hazelcast.cp.internal.datastructures.semaphore.client; import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreDrainCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreDrainCodec; import com.hazelcast.client.impl.protocol.task.AbstractMessageTask; import com.hazelcast.core.ExecutionCallback; import com.hazelcast.cp.internal.RaftOp; import com.hazelcast.cp.internal.RaftService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.operation.DrainPermitsOp; import com.hazelcast.instance.impl.Node; import com.hazelcast.nio.Connection; @@ -34,7 +34,7 @@ /** * Client message task for {@link DrainPermitsOp} */ -public class DrainPermitsMessageTask extends AbstractMessageTask +public class DrainPermitsMessageTask extends AbstractMessageTask implements ExecutionCallback { public DrainPermitsMessageTask(ClientMessage clientMessage, Node node, Connection connection) { @@ -49,18 +49,18 @@ protected void processMessage() { } @Override - protected CPSemaphoreDrainCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return CPSemaphoreDrainCodec.decodeRequest(clientMessage); + protected SemaphoreDrainCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { + return SemaphoreDrainCodec.decodeRequest(clientMessage); } @Override protected ClientMessage encodeResponse(Object response) { - return CPSemaphoreDrainCodec.encodeResponse((Integer) response); + return SemaphoreDrainCodec.encodeResponse((Integer) response); } @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/GetSemaphoreTypeMessageTask.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/GetSemaphoreTypeMessageTask.java index 1deefe71b7792..aa2674ff009f9 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/GetSemaphoreTypeMessageTask.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/GetSemaphoreTypeMessageTask.java @@ -17,10 +17,10 @@ package com.hazelcast.cp.internal.datastructures.semaphore.client; import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreGetSemaphoreTypeCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreGetSemaphoreTypeCodec; import com.hazelcast.client.impl.protocol.task.AbstractMessageTask; -import com.hazelcast.config.cp.CPSemaphoreConfig; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.config.cp.SemaphoreConfig; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.instance.impl.Node; import com.hazelcast.nio.Connection; @@ -29,7 +29,7 @@ /** * Client message task for querying semaphore JDK compatibility */ -public class GetSemaphoreTypeMessageTask extends AbstractMessageTask { +public class GetSemaphoreTypeMessageTask extends AbstractMessageTask { public GetSemaphoreTypeMessageTask(ClientMessage clientMessage, Node node, Connection connection) { super(clientMessage, node, connection); @@ -37,24 +37,24 @@ public GetSemaphoreTypeMessageTask(ClientMessage clientMessage, Node node, Conne @Override protected void processMessage() { - CPSemaphoreConfig config = nodeEngine.getConfig().getCPSubsystemConfig().findSemaphoreConfig(parameters.proxyName); + SemaphoreConfig config = nodeEngine.getConfig().getCPSubsystemConfig().findSemaphoreConfig(parameters.proxyName); boolean jdkCompatible = (config != null && config.isJDKCompatible()); sendResponse(jdkCompatible); } @Override - protected CPSemaphoreGetSemaphoreTypeCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return CPSemaphoreGetSemaphoreTypeCodec.decodeRequest(clientMessage); + protected SemaphoreGetSemaphoreTypeCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { + return SemaphoreGetSemaphoreTypeCodec.decodeRequest(clientMessage); } @Override protected ClientMessage encodeResponse(Object response) { - return CPSemaphoreGetSemaphoreTypeCodec.encodeResponse((Boolean) response); + return SemaphoreGetSemaphoreTypeCodec.encodeResponse((Boolean) response); } @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/InitSemaphoreMessageTask.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/InitSemaphoreMessageTask.java index 27da7fec67fa8..16955bbd7b78c 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/InitSemaphoreMessageTask.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/InitSemaphoreMessageTask.java @@ -17,11 +17,11 @@ package com.hazelcast.cp.internal.datastructures.semaphore.client; import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreInitCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreInitCodec; import com.hazelcast.client.impl.protocol.task.AbstractMessageTask; import com.hazelcast.core.ExecutionCallback; import com.hazelcast.cp.internal.RaftService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.operation.InitSemaphoreOp; import com.hazelcast.instance.impl.Node; import com.hazelcast.nio.Connection; @@ -33,7 +33,7 @@ /** * Client message task for {@link InitSemaphoreOp} */ -public class InitSemaphoreMessageTask extends AbstractMessageTask +public class InitSemaphoreMessageTask extends AbstractMessageTask implements ExecutionCallback { public InitSemaphoreMessageTask(ClientMessage clientMessage, Node node, Connection connection) { @@ -49,18 +49,18 @@ protected void processMessage() { } @Override - protected CPSemaphoreInitCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return CPSemaphoreInitCodec.decodeRequest(clientMessage); + protected SemaphoreInitCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { + return SemaphoreInitCodec.decodeRequest(clientMessage); } @Override protected ClientMessage encodeResponse(Object response) { - return CPSemaphoreInitCodec.encodeResponse((Boolean) response); + return SemaphoreInitCodec.encodeResponse((Boolean) response); } @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/ReleasePermitsMessageTask.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/ReleasePermitsMessageTask.java index 857197ae0f410..27d34e00601a9 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/ReleasePermitsMessageTask.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/client/ReleasePermitsMessageTask.java @@ -17,12 +17,12 @@ package com.hazelcast.cp.internal.datastructures.semaphore.client; import com.hazelcast.client.impl.protocol.ClientMessage; -import com.hazelcast.client.impl.protocol.codec.CPSemaphoreReleaseCodec; +import com.hazelcast.client.impl.protocol.codec.SemaphoreReleaseCodec; import com.hazelcast.client.impl.protocol.task.AbstractMessageTask; import com.hazelcast.core.ExecutionCallback; import com.hazelcast.cp.internal.RaftOp; import com.hazelcast.cp.internal.RaftService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.operation.ReleasePermitsOp; import com.hazelcast.instance.impl.Node; import com.hazelcast.nio.Connection; @@ -34,7 +34,7 @@ /** * Client message task for {@link ReleasePermitsOp} */ -public class ReleasePermitsMessageTask extends AbstractMessageTask +public class ReleasePermitsMessageTask extends AbstractMessageTask implements ExecutionCallback { public ReleasePermitsMessageTask(ClientMessage clientMessage, Node node, Connection connection) { @@ -52,18 +52,18 @@ protected void processMessage() { } @Override - protected CPSemaphoreReleaseCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { - return CPSemaphoreReleaseCodec.decodeRequest(clientMessage); + protected SemaphoreReleaseCodec.RequestParameters decodeClientMessage(ClientMessage clientMessage) { + return SemaphoreReleaseCodec.decodeRequest(clientMessage); } @Override protected ClientMessage encodeResponse(Object response) { - return CPSemaphoreReleaseCodec.encodeResponse((Boolean) response); + return SemaphoreReleaseCodec.encodeResponse((Boolean) response); } @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AbstractSemaphoreOp.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AbstractSemaphoreOp.java index 8571c2ac907e0..c2b96edb11a11 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AbstractSemaphoreOp.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AbstractSemaphoreOp.java @@ -17,8 +17,8 @@ package com.hazelcast.cp.internal.datastructures.semaphore.operation; import com.hazelcast.cp.internal.RaftOp; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreDataSerializerHook; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreEndpoint; import com.hazelcast.nio.ObjectDataInput; import com.hazelcast.nio.ObjectDataOutput; @@ -56,12 +56,12 @@ SemaphoreEndpoint getSemaphoreEndpoint() { @Override protected String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override public int getFactoryId() { - return RaftSemaphoreDataSerializerHook.F_ID; + return SemaphoreDataSerializerHook.F_ID; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AcquirePermitsOp.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AcquirePermitsOp.java index bc7c7bb988e58..ef31b05af286f 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AcquirePermitsOp.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AcquirePermitsOp.java @@ -21,9 +21,9 @@ import com.hazelcast.cp.internal.CallerAware; import com.hazelcast.cp.internal.IndeterminateOperationStateAware; import com.hazelcast.cp.internal.datastructures.semaphore.AcquireInvocationKey; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreDataSerializerHook; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.raft.impl.util.PostponedResponse; import com.hazelcast.nio.Address; import com.hazelcast.nio.ObjectDataInput; @@ -37,7 +37,7 @@ /** * Operation for {@link ISemaphore#acquire()} * - * @see RaftSemaphore#acquire(AcquireInvocationKey, boolean) + * @see Semaphore#acquire(AcquireInvocationKey, boolean) */ public class AcquirePermitsOp extends AbstractSemaphoreOp implements CallerAware, IndeterminateOperationStateAware { @@ -57,7 +57,7 @@ public AcquirePermitsOp(String name, long sessionId, long threadId, UUID invocat @Override public Object run(CPGroupId groupId, long commitIndex) { - RaftSemaphoreService service = getService(); + SemaphoreService service = getService(); AcquireInvocationKey key = new AcquireInvocationKey(commitIndex, invocationUid, callerAddress, callId, getSemaphoreEndpoint(), permits); boolean acquired = service.acquirePermits(groupId, name, key, timeoutMs); @@ -80,7 +80,7 @@ public boolean isRetryableOnIndeterminateOperationState() { @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.ACQUIRE_PERMITS_OP; + return SemaphoreDataSerializerHook.ACQUIRE_PERMITS_OP; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AvailablePermitsOp.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AvailablePermitsOp.java index 26e08dce4904b..7c0f3ad4686cb 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AvailablePermitsOp.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AvailablePermitsOp.java @@ -17,9 +17,9 @@ package com.hazelcast.cp.internal.datastructures.semaphore.operation; import com.hazelcast.cp.ISemaphore; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreDataSerializerHook; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.nio.ObjectDataInput; import com.hazelcast.nio.ObjectDataOutput; import com.hazelcast.nio.serialization.IdentifiedDataSerializable; @@ -32,7 +32,7 @@ /** * Operation for {@link ISemaphore#availablePermits()} * - * @see RaftSemaphore#getAvailable() + * @see Semaphore#getAvailable() */ public class AvailablePermitsOp extends RaftOp implements IndeterminateOperationStateAware, IdentifiedDataSerializable { @@ -47,7 +47,7 @@ public AvailablePermitsOp(String name) { @Override public Object run(CPGroupId groupId, long commitIndex) { - RaftSemaphoreService service = getService(); + SemaphoreService service = getService(); return service.availablePermits(groupId, name); } @@ -58,17 +58,17 @@ public boolean isRetryableOnIndeterminateOperationState() { @Override protected String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override public int getFactoryId() { - return RaftSemaphoreDataSerializerHook.F_ID; + return SemaphoreDataSerializerHook.F_ID; } @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.AVAILABLE_PERMITS_OP; + return SemaphoreDataSerializerHook.AVAILABLE_PERMITS_OP; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ChangePermitsOp.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ChangePermitsOp.java index 76ffcc7677a75..829645b4259e2 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ChangePermitsOp.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ChangePermitsOp.java @@ -19,9 +19,9 @@ import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.CPGroupId; import com.hazelcast.cp.internal.IndeterminateOperationStateAware; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreDataSerializerHook; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.nio.ObjectDataInput; import com.hazelcast.nio.ObjectDataOutput; import com.hazelcast.nio.serialization.IdentifiedDataSerializable; @@ -35,7 +35,7 @@ * Operation for {@link ISemaphore#increasePermits(int)} * and {@link ISemaphore#reducePermits(int)} * - * @see RaftSemaphore#change(long, long, UUID, int) + * @see Semaphore#change(long, long, UUID, int) */ public class ChangePermitsOp extends AbstractSemaphoreOp implements IndeterminateOperationStateAware, IdentifiedDataSerializable { @@ -51,7 +51,7 @@ public ChangePermitsOp(String name, long sessionId, long threadId, UUID invocati @Override public Object run(CPGroupId groupId, long commitIndex) { - RaftSemaphoreService service = getService(); + SemaphoreService service = getService(); return service.changePermits(groupId, commitIndex, name, getSemaphoreEndpoint(), invocationUid, permits); } @@ -62,17 +62,17 @@ public boolean isRetryableOnIndeterminateOperationState() { @Override protected String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override public int getFactoryId() { - return RaftSemaphoreDataSerializerHook.F_ID; + return SemaphoreDataSerializerHook.F_ID; } @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.CHANGE_PERMITS_OP; + return SemaphoreDataSerializerHook.CHANGE_PERMITS_OP; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/DrainPermitsOp.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/DrainPermitsOp.java index 1771a4470dd5e..fcc8bd24c317c 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/DrainPermitsOp.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/DrainPermitsOp.java @@ -19,9 +19,9 @@ import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.CPGroupId; import com.hazelcast.cp.internal.IndeterminateOperationStateAware; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreDataSerializerHook; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import java.util.UUID; @@ -30,7 +30,7 @@ /** * Operation for {@link ISemaphore#drainPermits()}} * - * @see RaftSemaphore#drain(long, long, UUID) + * @see Semaphore#drain(long, long, UUID) */ public class DrainPermitsOp extends AbstractSemaphoreOp implements IndeterminateOperationStateAware { @@ -43,7 +43,7 @@ public DrainPermitsOp(String name, long sessionId, long threadId, UUID invocatio @Override public Object run(CPGroupId groupId, long commitIndex) { - RaftSemaphoreService service = getService(); + SemaphoreService service = getService(); return service.drainPermits(groupId, name, commitIndex, getSemaphoreEndpoint(), invocationUid); } @@ -54,6 +54,6 @@ public boolean isRetryableOnIndeterminateOperationState() { @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.DRAIN_PERMITS_OP; + return SemaphoreDataSerializerHook.DRAIN_PERMITS_OP; } } diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/InitSemaphoreOp.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/InitSemaphoreOp.java index f51e242d96a69..6e8c9aecb9311 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/InitSemaphoreOp.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/InitSemaphoreOp.java @@ -17,9 +17,9 @@ package com.hazelcast.cp.internal.datastructures.semaphore.operation; import com.hazelcast.cp.ISemaphore; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreDataSerializerHook; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.nio.ObjectDataInput; import com.hazelcast.nio.ObjectDataOutput; import com.hazelcast.nio.serialization.IdentifiedDataSerializable; @@ -32,7 +32,7 @@ /** * Operation for {@link ISemaphore#init(int)} * - * @see RaftSemaphore#init(int) + * @see Semaphore#init(int) */ public class InitSemaphoreOp extends RaftOp implements IndeterminateOperationStateAware, IdentifiedDataSerializable { @@ -49,7 +49,7 @@ public InitSemaphoreOp(String name, int permits) { @Override public Object run(CPGroupId groupId, long commitIndex) { - RaftSemaphoreService service = getService(); + SemaphoreService service = getService(); return service.initSemaphore(groupId, name, permits); } @@ -60,17 +60,17 @@ public boolean isRetryableOnIndeterminateOperationState() { @Override protected String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override public int getFactoryId() { - return RaftSemaphoreDataSerializerHook.F_ID; + return SemaphoreDataSerializerHook.F_ID; } @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.INIT_SEMAPHORE_OP; + return SemaphoreDataSerializerHook.INIT_SEMAPHORE_OP; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ReleasePermitsOp.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ReleasePermitsOp.java index c62a1cb9f9417..bce00f9e2f77b 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ReleasePermitsOp.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ReleasePermitsOp.java @@ -19,9 +19,9 @@ import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.CPGroupId; import com.hazelcast.cp.internal.IndeterminateOperationStateAware; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphore; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.Semaphore; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreDataSerializerHook; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.nio.ObjectDataInput; import com.hazelcast.nio.ObjectDataOutput; @@ -33,7 +33,7 @@ /** * Operation for {@link ISemaphore#release()} * - * @see RaftSemaphore#release(long, long, UUID, int) + * @see Semaphore#release(long, long, UUID, int) */ public class ReleasePermitsOp extends AbstractSemaphoreOp implements IndeterminateOperationStateAware { @@ -49,7 +49,7 @@ public ReleasePermitsOp(String name, long sessionId, long threadId, UUID invocat @Override public Object run(CPGroupId groupId, long commitIndex) { - RaftSemaphoreService service = getService(); + SemaphoreService service = getService(); service.releasePermits(groupId, commitIndex, name, getSemaphoreEndpoint(), invocationUid, permits); return true; } @@ -61,7 +61,7 @@ public boolean isRetryableOnIndeterminateOperationState() { @Override public int getClassId() { - return RaftSemaphoreDataSerializerHook.RELEASE_PERMITS_OP; + return SemaphoreDataSerializerHook.RELEASE_PERMITS_OP; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/RaftSessionAwareSemaphoreProxy.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/SessionAwareSemaphoreProxy.java similarity index 96% rename from hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/RaftSessionAwareSemaphoreProxy.java rename to hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/SessionAwareSemaphoreProxy.java index 352ea9fb0e629..9ece67f41be90 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/RaftSessionAwareSemaphoreProxy.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/SessionAwareSemaphoreProxy.java @@ -21,7 +21,7 @@ import com.hazelcast.cp.internal.RaftInvocationManager; import com.hazelcast.cp.internal.RaftOp; import com.hazelcast.cp.internal.RaftService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.operation.AcquirePermitsOp; import com.hazelcast.cp.internal.datastructures.semaphore.operation.AvailablePermitsOp; import com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp; @@ -50,7 +50,7 @@ /** * Server-side session-aware proxy of Raft-based {@link ISemaphore} */ -public class RaftSessionAwareSemaphoreProxy extends SessionAwareProxy implements ISemaphore { +public class SessionAwareSemaphoreProxy extends SessionAwareProxy implements ISemaphore { /** * Since a proxy does not know how many permits will be drained on @@ -64,7 +64,7 @@ public class RaftSessionAwareSemaphoreProxy extends SessionAwareProxy implements private final String proxyName; private final String objectName; - public RaftSessionAwareSemaphoreProxy(NodeEngine nodeEngine, RaftGroupId groupId, String proxyName, String objectName) { + public SessionAwareSemaphoreProxy(NodeEngine nodeEngine, RaftGroupId groupId, String proxyName, String objectName) { super(nodeEngine.getService(ProxySessionManagerService.SERVICE_NAME), groupId); RaftService service = nodeEngine.getService(RaftService.SERVICE_NAME); this.invocationManager = service.getInvocationManager(); @@ -256,7 +256,7 @@ public String getPartitionKey() { @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/RaftSessionlessSemaphoreProxy.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/SessionlessSemaphoreProxy.java similarity index 94% rename from hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/RaftSessionlessSemaphoreProxy.java rename to hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/SessionlessSemaphoreProxy.java index 9cfaf25e4ac4a..8208b4c8ce218 100644 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/RaftSessionlessSemaphoreProxy.java +++ b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/SessionlessSemaphoreProxy.java @@ -21,7 +21,7 @@ import com.hazelcast.cp.internal.RaftInvocationManager; import com.hazelcast.cp.internal.RaftOp; import com.hazelcast.cp.internal.RaftService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.semaphore.operation.AcquirePermitsOp; import com.hazelcast.cp.internal.datastructures.semaphore.operation.AvailablePermitsOp; import com.hazelcast.cp.internal.datastructures.semaphore.operation.ChangePermitsOp; @@ -45,13 +45,13 @@ /** * Server-side sessionless proxy of Raft-based {@link ISemaphore} */ -public class RaftSessionlessSemaphoreProxy extends SessionAwareProxy implements ISemaphore { +public class SessionlessSemaphoreProxy extends SessionAwareProxy implements ISemaphore { private final RaftInvocationManager invocationManager; private final String proxyName; private final String objectName; - public RaftSessionlessSemaphoreProxy(NodeEngine nodeEngine, RaftGroupId groupId, String proxyName, String objectName) { + public SessionlessSemaphoreProxy(NodeEngine nodeEngine, RaftGroupId groupId, String proxyName, String objectName) { super(nodeEngine.getService(ProxySessionManagerService.SERVICE_NAME), groupId); RaftService service = nodeEngine.getService(RaftService.SERVICE_NAME); this.invocationManager = service.getInvocationManager(); @@ -161,7 +161,7 @@ public String getPartitionKey() { @Override public String getServiceName() { - return RaftSemaphoreService.SERVICE_NAME; + return SemaphoreService.SERVICE_NAME; } @Override diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreContainer.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreContainer.java deleted file mode 100644 index 84f801b7db07b..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreContainer.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore; - -import com.hazelcast.config.SemaphoreConfig; -import com.hazelcast.nio.ObjectDataInput; -import com.hazelcast.nio.ObjectDataOutput; -import com.hazelcast.nio.serialization.IdentifiedDataSerializable; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import static com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook.CONTAINER; -import static com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook.F_ID; -import static com.hazelcast.internal.util.MapUtil.createHashMap; - -public class SemaphoreContainer implements IdentifiedDataSerializable { - - public static final int INITIAL_CAPACITY = 10; - - private int available; - private int partitionId; - private Map attachMap; - private int backupCount; - private int asyncBackupCount; - private boolean initialized; - - public SemaphoreContainer() { - } - - public SemaphoreContainer(int partitionId, SemaphoreConfig config) { - this.partitionId = partitionId; - this.backupCount = config.getBackupCount(); - this.asyncBackupCount = config.getAsyncBackupCount(); - this.available = config.getInitialPermits(); - this.attachMap = new HashMap(INITIAL_CAPACITY); - } - - private void attach(String owner, int permitCount) { - Integer attached = attachMap.get(owner); - if (attached == null) { - attached = 0; - } - attachMap.put(owner, attached + permitCount); - } - - private void detach(String owner, int permitCount) { - Integer attached = attachMap.get(owner); - if (attached == null) { - return; - } - - attached -= permitCount; - if (attached <= 0) { - attachMap.remove(owner); - } else { - attachMap.put(owner, attached); - } - } - - public boolean detachAll(String owner) { - Integer attached = attachMap.remove(owner); - if (attached != null) { - available += attached; - return true; - } - return false; - } - - public boolean init(int permitCount) { - if (initialized || available != 0) { - return false; - } - available = permitCount; - initialized = true; - return true; - } - - public int getAvailable() { - return available; - } - - public boolean isAvailable(int permitCount) { - return available > 0 && available - permitCount >= 0; - } - - public boolean acquire(String owner, int permitCount) { - if (isAvailable(permitCount)) { - available -= permitCount; - attach(owner, permitCount); - initialized = true; - return true; - } - return false; - } - - public int drain(String owner) { - int drain = available; - available = 0; - if (drain > 0) { - initialized = true; - attach(owner, drain); - } - return drain; - } - - public boolean increase(int permitCount) { - if (permitCount == 0) { - return false; - } - int newAvailable = available + permitCount; - if (newAvailable < available) { - return false; - } - available = newAvailable; - return true; - } - - public boolean reduce(int permitCount) { - if (permitCount == 0) { - return false; - } - int newAvailable = available - permitCount; - if (newAvailable > available) { - return false; - } - available = newAvailable; - return true; - } - - public void release(String owner, int permitCount) { - available += permitCount; - initialized = true; - detach(owner, permitCount); - } - - public int getPartitionId() { - return partitionId; - } - - public int getSyncBackupCount() { - return backupCount; - } - - public int getAsyncBackupCount() { - return asyncBackupCount; - } - - public void setInitialized() { - this.initialized = true; - } - - public int getTotalBackupCount() { - return backupCount + asyncBackupCount; - } - - @Override - public int getFactoryId() { - return F_ID; - } - - @Override - public int getClassId() { - return CONTAINER; - } - - @Override - public void writeData(ObjectDataOutput out) throws IOException { - out.writeInt(available); - out.writeInt(partitionId); - out.writeInt(backupCount); - out.writeInt(asyncBackupCount); - out.writeInt(attachMap.size()); - for (Map.Entry entry : attachMap.entrySet()) { - out.writeUTF(entry.getKey()); - out.writeInt(entry.getValue()); - } - } - - @Override - public void readData(ObjectDataInput in) throws IOException { - available = in.readInt(); - partitionId = in.readInt(); - backupCount = in.readInt(); - asyncBackupCount = in.readInt(); - int size = in.readInt(); - attachMap = createHashMap(size); - for (int i = 0; i < size; i++) { - String owner = in.readUTF(); - Integer val = in.readInt(); - attachMap.put(owner, val); - } - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("Permit"); - sb.append("{available=").append(available); - sb.append(", partitionId=").append(partitionId); - sb.append(", backupCount=").append(backupCount); - sb.append(", asyncBackupCount=").append(asyncBackupCount); - sb.append('}'); - sb.append("\n"); - for (Map.Entry entry : attachMap.entrySet()) { - sb.append("{owner=").append(entry.getKey()); - sb.append(", attached=").append(entry.getValue()); - sb.append("} "); - } - return sb.toString(); - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreDataSerializerHook.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreDataSerializerHook.java deleted file mode 100644 index 05ac323148f30..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreDataSerializerHook.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.AcquireBackupOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.AcquireOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.AvailableOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.DrainBackupOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.DrainOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.IncreaseBackupOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.IncreaseOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.InitBackupOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.InitOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.ReduceBackupOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.ReduceOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.ReleaseBackupOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.ReleaseOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.SemaphoreDetachMemberBackupOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.SemaphoreDetachMemberOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.SemaphoreReplicationOperation; -import com.hazelcast.internal.serialization.DataSerializerHook; -import com.hazelcast.internal.serialization.impl.FactoryIdHelper; -import com.hazelcast.nio.serialization.DataSerializableFactory; -import com.hazelcast.nio.serialization.IdentifiedDataSerializable; - -import static com.hazelcast.internal.serialization.impl.FactoryIdHelper.SEMAPHORE_DS_FACTORY; -import static com.hazelcast.internal.serialization.impl.FactoryIdHelper.SEMAPHORE_DS_FACTORY_ID; - -public class SemaphoreDataSerializerHook implements DataSerializerHook { - - public static final int F_ID = FactoryIdHelper.getFactoryId(SEMAPHORE_DS_FACTORY, SEMAPHORE_DS_FACTORY_ID); - - public static final int CONTAINER = 0; - public static final int ACQUIRE_BACKUP_OPERATION = 1; - public static final int ACQUIRE_OPERATION = 2; - public static final int AVAILABLE_OPERATION = 3; - public static final int DETACH_MEMBER_BACKUP_OPERATION = 4; - public static final int DRAIN_BACKUP_OPERATION = 5; - public static final int DRAIN_OPERATION = 6; - public static final int INIT_BACKUP_OPERATION = 7; - public static final int INIT_OPERATION = 8; - public static final int REDUCE_BACKUP_OPERATION = 9; - public static final int REDUCE_OPERATION = 10; - public static final int RELEASE_BACKUP_OPERATION = 11; - public static final int RELEASE_OPERATION = 12; - public static final int DETACH_MEMBER_OPERATION = 13; - public static final int SEMAPHORE_REPLICATION_OPERATION = 14; - public static final int INCREASE_OPERATION = 15; - public static final int INCREASE_BACKUP_OPERATION = 16; - - @Override - public int getFactoryId() { - return F_ID; - } - - @Override - public DataSerializableFactory createFactory() { - return new DataSerializableFactory() { - @Override - public IdentifiedDataSerializable create(int typeId) { - switch (typeId) { - case CONTAINER: - return new SemaphoreContainer(); - case ACQUIRE_BACKUP_OPERATION: - return new AcquireBackupOperation(); - case ACQUIRE_OPERATION: - return new AcquireOperation(); - case AVAILABLE_OPERATION: - return new AvailableOperation(); - case DETACH_MEMBER_BACKUP_OPERATION: - return new SemaphoreDetachMemberBackupOperation(); - case DRAIN_BACKUP_OPERATION: - return new DrainBackupOperation(); - case DRAIN_OPERATION: - return new DrainOperation(); - case INIT_BACKUP_OPERATION: - return new InitBackupOperation(); - case INIT_OPERATION: - return new InitOperation(); - case REDUCE_BACKUP_OPERATION: - return new ReduceBackupOperation(); - case REDUCE_OPERATION: - return new ReduceOperation(); - case RELEASE_BACKUP_OPERATION: - return new ReleaseBackupOperation(); - case RELEASE_OPERATION: - return new ReleaseOperation(); - case DETACH_MEMBER_OPERATION: - return new SemaphoreDetachMemberOperation(); - case SEMAPHORE_REPLICATION_OPERATION: - return new SemaphoreReplicationOperation(); - case INCREASE_OPERATION: - return new IncreaseOperation(); - case INCREASE_BACKUP_OPERATION: - return new IncreaseBackupOperation(); - default: - return null; - } - } - }; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreProxy.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreProxy.java deleted file mode 100644 index f42f8a8058811..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreProxy.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.AcquireOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.AvailableOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.DrainOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.IncreaseOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.InitOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.ReduceOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.ReleaseOperation; -import com.hazelcast.cp.ISemaphore; -import com.hazelcast.spi.impl.AbstractDistributedObject; -import com.hazelcast.spi.impl.InternalCompletableFuture; -import com.hazelcast.spi.impl.NodeEngine; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import static com.hazelcast.internal.util.ExceptionUtil.rethrowAllowInterrupted; -import static com.hazelcast.internal.util.Preconditions.checkNotNegative; -import static java.lang.Thread.currentThread; - -public class SemaphoreProxy extends AbstractDistributedObject implements ISemaphore { - - private final String name; - private final int partitionId; - - public SemaphoreProxy(String name, SemaphoreService service, NodeEngine nodeEngine) { - super(nodeEngine, service); - this.name = name; - this.partitionId = nodeEngine.getPartitionService().getPartitionId(getNameAsPartitionAwareData()); - } - - @Override - public String getName() { - return name; - } - - @Override - public boolean init(int permits) { - checkNotNegative(permits, "permits can't be negative"); - - Operation operation = new InitOperation(name, permits) - .setPartitionId(partitionId); - InternalCompletableFuture future = invokeOnPartition(operation); - return future.join(); - } - - @Override - public void acquire() throws InterruptedException { - acquire(1); - } - - @Override - public void acquire(int permits) throws InterruptedException { - checkNotNegative(permits, "permits can't be negative"); - - try { - Operation operation = new AcquireOperation(name, permits, -1) - .setPartitionId(partitionId); - InternalCompletableFuture future = invokeOnPartition(operation); - future.get(); - } catch (Throwable t) { - throw rethrowAllowInterrupted(t); - } - } - - @Override - public int availablePermits() { - Operation operation = new AvailableOperation(name) - .setPartitionId(partitionId); - InternalCompletableFuture future = invokeOnPartition(operation); - return future.join(); - } - - @Override - public int drainPermits() { - Operation operation = new DrainOperation(name) - .setPartitionId(partitionId); - InternalCompletableFuture future = invokeOnPartition(operation); - return future.join(); - } - - @Override - public void reducePermits(int reduction) { - checkNotNegative(reduction, "reduction can't be negative"); - - Operation operation = new ReduceOperation(name, reduction) - .setPartitionId(partitionId); - InternalCompletableFuture future = invokeOnPartition(operation); - future.join(); - } - - @Override - public void increasePermits(int increase) { - checkNotNegative(increase, "increase can't be negative"); - - Operation operation = new IncreaseOperation(name, increase) - .setPartitionId(partitionId); - InternalCompletableFuture future = invokeOnPartition(operation); - future.join(); - } - - @Override - public void release() { - release(1); - } - - @Override - public void release(int permits) { - checkNotNegative(permits, "permits can't be negative"); - - Operation operation = new ReleaseOperation(name, permits) - .setPartitionId(partitionId); - InternalCompletableFuture future = invokeOnPartition(operation); - future.join(); - } - - @Override - public boolean tryAcquire() { - try { - return tryAcquire(1, 0, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - currentThread().interrupt(); - return false; - } - } - - @Override - public boolean tryAcquire(int permits) { - try { - return tryAcquire(permits, 0, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - currentThread().interrupt(); - return false; - } - } - - @Override - public boolean tryAcquire(long timeout, TimeUnit unit) throws InterruptedException { - return tryAcquire(1, timeout, unit); - } - - @Override - public boolean tryAcquire(int permits, long timeout, TimeUnit unit) throws InterruptedException { - checkNotNegative(permits, "permits can't be negative"); - - try { - Operation operation = new AcquireOperation(name, permits, unit.toMillis(timeout)) - .setPartitionId(partitionId); - Future future = invokeOnPartition(operation); - return future.get(); - } catch (Throwable t) { - throw rethrowAllowInterrupted(t); - } - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public String toString() { - return "ISemaphore{name='" + name + '\'' + '}'; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreService.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreService.java deleted file mode 100644 index fca10ab9f5ecf..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreService.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore; - -import com.hazelcast.config.SemaphoreConfig; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.SemaphoreDetachMemberOperation; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations.SemaphoreReplicationOperation; -import com.hazelcast.internal.services.ClientAwareService; -import com.hazelcast.internal.services.ManagedService; -import com.hazelcast.internal.services.MemberAttributeServiceEvent; -import com.hazelcast.internal.services.MembershipAwareService; -import com.hazelcast.internal.services.MembershipServiceEvent; -import com.hazelcast.internal.services.RemoteService; -import com.hazelcast.internal.services.SplitBrainProtectionAwareService; -import com.hazelcast.spi.impl.NodeEngine; -import com.hazelcast.spi.impl.operationservice.Operation; -import com.hazelcast.spi.impl.operationservice.OperationService; -import com.hazelcast.spi.partition.IPartitionService; -import com.hazelcast.spi.partition.MigrationAwareService; -import com.hazelcast.spi.partition.MigrationEndpoint; -import com.hazelcast.spi.partition.PartitionMigrationEvent; -import com.hazelcast.spi.partition.PartitionReplicationEvent; -import com.hazelcast.internal.util.ConstructorFunction; -import com.hazelcast.internal.util.ContextMutexFactory; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import static com.hazelcast.partition.strategy.StringPartitioningStrategy.getPartitionKey; -import static com.hazelcast.internal.util.ConcurrencyUtil.getOrPutIfAbsent; -import static com.hazelcast.internal.util.ConcurrencyUtil.getOrPutSynchronized; - -public class SemaphoreService implements ManagedService, MigrationAwareService, MembershipAwareService, RemoteService, - ClientAwareService, SplitBrainProtectionAwareService { - - public static final String SERVICE_NAME = "hz:impl:semaphoreService"; - - private static final Object NULL_OBJECT = new Object(); - - private final ConcurrentMap containers = new ConcurrentHashMap(); - - private final ConcurrentMap splitBrainProtectionConfigCache = new ConcurrentHashMap(); - private final ContextMutexFactory splitBrainProtectionConfigCacheMutexFactory = new ContextMutexFactory(); - private final ConstructorFunction splitBrainProtectionConfigConstructor = - new ConstructorFunction() { - @Override - public Object createNew(String name) { - SemaphoreConfig semaphoreConfig = nodeEngine.getConfig().findSemaphoreConfig(name); - String splitBrainProtectionName = semaphoreConfig.getSplitBrainProtectionName(); - return splitBrainProtectionName == null ? NULL_OBJECT : splitBrainProtectionName; - } - }; - - private final ConstructorFunction containerConstructor - = new ConstructorFunction() { - @Override - public SemaphoreContainer createNew(String name) { - SemaphoreConfig config = nodeEngine.getConfig().findSemaphoreConfig(name); - IPartitionService partitionService = nodeEngine.getPartitionService(); - int partitionId = partitionService.getPartitionId(getPartitionKey(name)); - return new SemaphoreContainer(partitionId, new SemaphoreConfig(config)); - } - }; - private final NodeEngine nodeEngine; - - public SemaphoreService(NodeEngine nodeEngine) { - this.nodeEngine = nodeEngine; - } - - public SemaphoreContainer getSemaphoreContainer(String name) { - return getOrPutIfAbsent(containers, name, containerConstructor); - } - - public boolean containsSemaphore(String name) { - return containers.containsKey(name); - } - - @Override - public void init(NodeEngine nodeEngine, Properties properties) { - } - - @Override - public void reset() { - containers.clear(); - } - - @Override - public void shutdown(boolean terminate) { - containers.clear(); - } - - @Override - public void memberAdded(MembershipServiceEvent event) { - } - - @Override - public void memberRemoved(MembershipServiceEvent event) { - onOwnerDisconnected(event.getMember().getUuid()); - } - - @Override - public void memberAttributeChanged(MemberAttributeServiceEvent event) { - } - - private void onOwnerDisconnected(final String owner) { - OperationService operationService = nodeEngine.getOperationService(); - - for (Map.Entry entry : containers.entrySet()) { - String name = entry.getKey(); - SemaphoreContainer container = entry.getValue(); - - Operation op = new SemaphoreDetachMemberOperation(name, owner) - .setPartitionId(container.getPartitionId()) - .setValidateTarget(false) - .setService(this) - .setNodeEngine(nodeEngine) - .setServiceName(SERVICE_NAME); - - // op will be executed on partition thread locally. - // Invocation is to handle retries (if partition is being migrated). - operationService.invokeOnTarget(SERVICE_NAME, op, nodeEngine.getThisAddress()); - } - } - - @Override - public SemaphoreProxy createDistributedObject(String objectId) { - return new SemaphoreProxy(objectId, this, nodeEngine); - } - - @Override - public void destroyDistributedObject(String objectId) { - containers.remove(objectId); - splitBrainProtectionConfigCache.remove(objectId); - } - - @Override - public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent) { - } - - @Override - public Operation prepareReplicationOperation(PartitionReplicationEvent event) { - Map migrationData = new HashMap(); - for (Map.Entry entry : containers.entrySet()) { - String name = entry.getKey(); - SemaphoreContainer semaphoreContainer = entry.getValue(); - if (semaphoreContainer.getPartitionId() == event.getPartitionId() - && semaphoreContainer.getTotalBackupCount() >= event.getReplicaIndex()) { - migrationData.put(name, semaphoreContainer); - } - } - - if (migrationData.isEmpty()) { - return null; - } - - return new SemaphoreReplicationOperation(migrationData); - } - - public void insertMigrationData(Map migrationData) { - containers.putAll(migrationData); - } - - @Override - public void commitMigration(PartitionMigrationEvent event) { - if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) { - clearSemaphoresHavingLesserBackupCountThan(event.getPartitionId(), event.getNewReplicaIndex()); - } - } - - @Override - public void rollbackMigration(PartitionMigrationEvent event) { - if (event.getMigrationEndpoint() == MigrationEndpoint.DESTINATION) { - clearSemaphoresHavingLesserBackupCountThan(event.getPartitionId(), event.getCurrentReplicaIndex()); - } - } - - private void clearSemaphoresHavingLesserBackupCountThan(int partitionId, int thresholdReplicaIndex) { - Iterator it = containers.values().iterator(); - while (it.hasNext()) { - SemaphoreContainer semaphoreContainer = it.next(); - if (semaphoreContainer.getPartitionId() != partitionId) { - continue; - } - - if (thresholdReplicaIndex < 0 || thresholdReplicaIndex > semaphoreContainer.getTotalBackupCount()) { - it.remove(); - } - } - } - - @Override - public void clientDisconnected(String clientUuid) { - onOwnerDisconnected(clientUuid); - } - - @Override - public String getSplitBrainProtectionName(final String name) { - Object splitBrainProtectionName = getOrPutSynchronized(splitBrainProtectionConfigCache, name, - splitBrainProtectionConfigCacheMutexFactory, splitBrainProtectionConfigConstructor); - return splitBrainProtectionName == NULL_OBJECT ? null : (String) splitBrainProtectionName; - } - -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreWaitNotifyKey.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreWaitNotifyKey.java deleted file mode 100644 index 5a7304420ad0c..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/SemaphoreWaitNotifyKey.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore; - -import com.hazelcast.spi.impl.operationservice.AbstractWaitNotifyKey; - -import static com.hazelcast.internal.util.Preconditions.isNotNull; - -public class SemaphoreWaitNotifyKey extends AbstractWaitNotifyKey { - - private final String type; - - public SemaphoreWaitNotifyKey(String name, String type) { - super(SemaphoreService.SERVICE_NAME, name); - this.type = isNotNull(type, "type"); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof SemaphoreWaitNotifyKey)) { - return false; - } - if (!super.equals(o)) { - return false; - } - - SemaphoreWaitNotifyKey that = (SemaphoreWaitNotifyKey) o; - - if (!type.equals(that.type)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + type.hashCode(); - return result; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AcquireBackupOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AcquireBackupOperation.java deleted file mode 100644 index 82ea05212848f..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AcquireBackupOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; - -public class AcquireBackupOperation extends SemaphoreBackupOperation { - - public AcquireBackupOperation() { - } - - public AcquireBackupOperation(String name, int permitCount, String firstCaller) { - super(name, permitCount, firstCaller); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - semaphoreContainer.acquire(firstCaller, permitCount); - response = true; - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.ACQUIRE_BACKUP_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AcquireOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AcquireOperation.java deleted file mode 100644 index 0d3bdc10bee9e..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AcquireOperation.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreWaitNotifyKey; -import com.hazelcast.spi.impl.operationservice.BlockingOperation; -import com.hazelcast.spi.impl.operationservice.Operation; -import com.hazelcast.spi.impl.operationservice.WaitNotifyKey; -import com.hazelcast.spi.impl.operationservice.MutatingOperation; - -import static java.lang.Boolean.TRUE; - -public class AcquireOperation extends SemaphoreBackupAwareOperation implements BlockingOperation, MutatingOperation { - - public AcquireOperation() { - } - - public AcquireOperation(String name, int permitCount, long timeout) { - super(name, permitCount); - setWaitTimeout(timeout); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - response = semaphoreContainer.acquire(getCallerUuid(), permitCount); - } - - @Override - public WaitNotifyKey getWaitKey() { - return new SemaphoreWaitNotifyKey(name, "acquire"); - } - - @Override - public boolean shouldWait() { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - return getWaitTimeout() != 0 && !semaphoreContainer.isAvailable(permitCount); - } - - @Override - public void onWaitExpire() { - sendResponse(false); - } - - @Override - public boolean shouldBackup() { - return TRUE.equals(response); - } - - @Override - public Operation getBackupOperation() { - return new AcquireBackupOperation(name, permitCount, getCallerUuid()); - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.ACQUIRE_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AvailableOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AvailableOperation.java deleted file mode 100644 index 4186428ed2285..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/AvailableOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.spi.impl.operationservice.ReadonlyOperation; - -public class AvailableOperation extends SemaphoreOperation implements ReadonlyOperation { - - public AvailableOperation() { - } - - public AvailableOperation(String name) { - super(name, -1); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - response = semaphoreContainer.getAvailable(); - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.AVAILABLE_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/DrainBackupOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/DrainBackupOperation.java deleted file mode 100644 index f640e471193dd..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/DrainBackupOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; - -public class DrainBackupOperation extends SemaphoreBackupOperation { - - public DrainBackupOperation() { - } - - public DrainBackupOperation(String name, int permitCount, String firstCaller) { - super(name, permitCount, firstCaller); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - semaphoreContainer.drain(firstCaller); - response = true; - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.DRAIN_BACKUP_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/DrainOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/DrainOperation.java deleted file mode 100644 index 9d2e08366723c..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/DrainOperation.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.spi.impl.operationservice.Operation; -import com.hazelcast.spi.impl.operationservice.MutatingOperation; - -public class DrainOperation extends SemaphoreBackupAwareOperation implements MutatingOperation { - - public DrainOperation() { - } - - public DrainOperation(String name) { - super(name, -1); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - response = semaphoreContainer.drain(getCallerUuid()); - } - - @Override - public boolean shouldBackup() { - return !response.equals(0); - } - - @Override - public Operation getBackupOperation() { - return new DrainBackupOperation(name, permitCount, getCallerUuid()); - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.DRAIN_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/IncreaseBackupOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/IncreaseBackupOperation.java deleted file mode 100644 index 65cefc6ad9f68..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/IncreaseBackupOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; - -public class IncreaseBackupOperation extends SemaphoreBackupOperation { - - public IncreaseBackupOperation() { - } - - public IncreaseBackupOperation(String name, int permitCount) { - super(name, permitCount, null); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - semaphoreContainer.increase(permitCount); - response = true; - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.INCREASE_BACKUP_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/IncreaseOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/IncreaseOperation.java deleted file mode 100644 index eadd2a597e9dc..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/IncreaseOperation.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.spi.impl.operationservice.Operation; -import com.hazelcast.spi.impl.operationservice.MutatingOperation; - -public class IncreaseOperation extends SemaphoreBackupAwareOperation implements MutatingOperation { - - public IncreaseOperation() { - } - - public IncreaseOperation(String name, int permitCount) { - super(name, permitCount); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - response = semaphoreContainer.increase(permitCount); - } - - @Override - public boolean shouldBackup() { - return Boolean.TRUE.equals(response); - } - - @Override - public Operation getBackupOperation() { - return new IncreaseBackupOperation(name, permitCount); - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.INCREASE_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/InitBackupOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/InitBackupOperation.java deleted file mode 100644 index 9c4e9aa3e5cbd..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/InitBackupOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; - -public class InitBackupOperation extends SemaphoreBackupOperation { - - public InitBackupOperation() { - } - - public InitBackupOperation(String name, int permitCount) { - super(name, permitCount, null); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - semaphoreContainer.init(permitCount); - response = true; - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.INIT_BACKUP_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/InitOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/InitOperation.java deleted file mode 100644 index f81b7feb85aba..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/InitOperation.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.spi.impl.operationservice.Operation; -import com.hazelcast.spi.impl.operationservice.MutatingOperation; - -import static java.lang.Boolean.TRUE; - -public class InitOperation extends SemaphoreBackupAwareOperation implements MutatingOperation { - - public InitOperation() { - } - - public InitOperation(String name, int permitCount) { - super(name, permitCount); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - response = semaphoreContainer.init(permitCount); - } - - @Override - public boolean shouldBackup() { - return TRUE.equals(response); - } - - @Override - public Operation getBackupOperation() { - return new InitBackupOperation(name, permitCount); - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.INIT_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReduceBackupOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReduceBackupOperation.java deleted file mode 100644 index 4be43e6529f24..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReduceBackupOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; - -public class ReduceBackupOperation extends SemaphoreBackupOperation { - - public ReduceBackupOperation() { - } - - public ReduceBackupOperation(String name, int permitCount) { - super(name, permitCount, null); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - semaphoreContainer.reduce(permitCount); - response = true; - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.REDUCE_BACKUP_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReduceOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReduceOperation.java deleted file mode 100644 index da640106fa99f..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReduceOperation.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.spi.impl.operationservice.Operation; -import com.hazelcast.spi.impl.operationservice.MutatingOperation; - -import static java.lang.Boolean.TRUE; - -public class ReduceOperation extends SemaphoreBackupAwareOperation implements MutatingOperation { - - public ReduceOperation() { - } - - public ReduceOperation(String name, int permitCount) { - super(name, permitCount); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - response = semaphoreContainer.reduce(permitCount); - } - - @Override - public boolean shouldBackup() { - return TRUE.equals(response); - } - - @Override - public Operation getBackupOperation() { - return new ReduceBackupOperation(name, permitCount); - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.REDUCE_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReleaseBackupOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReleaseBackupOperation.java deleted file mode 100644 index f713f4bf7de66..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReleaseBackupOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; - -public class ReleaseBackupOperation extends SemaphoreBackupOperation { - - public ReleaseBackupOperation() { - } - - public ReleaseBackupOperation(String name, int permitCount, String firstCaller) { - super(name, permitCount, firstCaller); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - semaphoreContainer.release(firstCaller, permitCount); - response = true; - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.RELEASE_BACKUP_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReleaseOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReleaseOperation.java deleted file mode 100644 index ccd9a129b11d7..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/ReleaseOperation.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreWaitNotifyKey; -import com.hazelcast.spi.impl.operationservice.Notifier; -import com.hazelcast.spi.impl.operationservice.Operation; -import com.hazelcast.spi.impl.operationservice.WaitNotifyKey; -import com.hazelcast.spi.impl.operationservice.MutatingOperation; - -public class ReleaseOperation extends SemaphoreBackupAwareOperation implements Notifier, MutatingOperation { - - public ReleaseOperation() { - } - - public ReleaseOperation(String name, int permitCount) { - super(name, permitCount); - } - - @Override - public void run() throws Exception { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - semaphoreContainer.release(getCallerUuid(), permitCount); - response = true; - } - - @Override - public boolean shouldNotify() { - return permitCount > 0; - } - - @Override - public WaitNotifyKey getNotifiedKey() { - return new SemaphoreWaitNotifyKey(name, "acquire"); - } - - @Override - public boolean shouldBackup() { - return permitCount > 0; - } - - @Override - public Operation getBackupOperation() { - return new ReleaseBackupOperation(name, permitCount, getCallerUuid()); - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.RELEASE_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreBackupAwareOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreBackupAwareOperation.java deleted file mode 100644 index ff9a62a7a86d1..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreBackupAwareOperation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.spi.impl.operationservice.BackupAwareOperation; - -public abstract class SemaphoreBackupAwareOperation extends SemaphoreOperation implements BackupAwareOperation { - - protected SemaphoreBackupAwareOperation() { - } - - protected SemaphoreBackupAwareOperation(String name, int permitCount) { - super(name, permitCount); - } - - @Override - public int getAsyncBackupCount() { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - return semaphoreContainer.getAsyncBackupCount(); - } - - @Override - public int getSyncBackupCount() { - SemaphoreContainer semaphoreContainer = getSemaphoreContainer(); - return semaphoreContainer.getSyncBackupCount(); - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreBackupOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreBackupOperation.java deleted file mode 100644 index f43935d728991..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreBackupOperation.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.nio.ObjectDataInput; -import com.hazelcast.nio.ObjectDataOutput; -import com.hazelcast.spi.impl.operationservice.BackupOperation; - -import java.io.IOException; - -public abstract class SemaphoreBackupOperation extends SemaphoreOperation implements BackupOperation { - - protected String firstCaller; - - protected SemaphoreBackupOperation() { - } - - protected SemaphoreBackupOperation(String name, int permitCount, String firstCaller) { - super(name, permitCount); - this.firstCaller = firstCaller; - } - - @Override - public void writeInternal(ObjectDataOutput out) throws IOException { - super.writeInternal(out); - out.writeUTF(firstCaller); - } - - @Override - public void readInternal(ObjectDataInput in) throws IOException { - super.readInternal(in); - firstCaller = in.readUTF(); - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreDetachMemberBackupOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreDetachMemberBackupOperation.java deleted file mode 100644 index f15fade278330..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreDetachMemberBackupOperation.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; - -public class SemaphoreDetachMemberBackupOperation extends SemaphoreBackupOperation { - - public SemaphoreDetachMemberBackupOperation() { - } - - public SemaphoreDetachMemberBackupOperation(String name, String firstCaller) { - super(name, -1, firstCaller); - } - - @Override - public void run() throws Exception { - SemaphoreService service = getService(); - if (service.containsSemaphore(name)) { - SemaphoreContainer semaphoreContainer = service.getSemaphoreContainer(name); - response = semaphoreContainer.detachAll(firstCaller); - } - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.DETACH_MEMBER_BACKUP_OPERATION; - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreDetachMemberOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreDetachMemberOperation.java deleted file mode 100644 index 0e7d83cb1b277..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreDetachMemberOperation.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreWaitNotifyKey; -import com.hazelcast.logging.ILogger; -import com.hazelcast.nio.ObjectDataInput; -import com.hazelcast.nio.ObjectDataOutput; -import com.hazelcast.spi.impl.NodeEngine; -import com.hazelcast.spi.impl.operationservice.Notifier; -import com.hazelcast.spi.impl.operationservice.Operation; -import com.hazelcast.spi.impl.operationservice.WaitNotifyKey; -import com.hazelcast.spi.partition.IPartition; -import com.hazelcast.spi.partition.IPartitionService; - -import java.io.IOException; - -public class SemaphoreDetachMemberOperation extends SemaphoreBackupAwareOperation implements Notifier { - - private String detachedMemberUuid; - - public SemaphoreDetachMemberOperation() { - } - - public SemaphoreDetachMemberOperation(String name, String detachedMemberUuid) { - super(name, -1); - this.detachedMemberUuid = detachedMemberUuid; - } - - @Override - public void run() throws Exception { - SemaphoreService service = getService(); - if (service.containsSemaphore(name)) { - SemaphoreContainer semaphoreContainer = service.getSemaphoreContainer(name); - response = semaphoreContainer.detachAll(detachedMemberUuid); - } - - ILogger logger = getLogger(); - if (logger.isFineEnabled()) { - logger.fine("Removing permits attached to " + detachedMemberUuid + ". Result: " + response); - } - } - - @Override - public boolean shouldBackup() { - final NodeEngine nodeEngine = getNodeEngine(); - IPartitionService partitionService = nodeEngine.getPartitionService(); - IPartition partition = partitionService.getPartition(getPartitionId()); - return partition.isLocal() && Boolean.TRUE.equals(response); - } - - @Override - public int getAsyncBackupCount() { - int syncBackupCount = super.getSyncBackupCount(); - int asyncBackupCount = super.getAsyncBackupCount(); - return syncBackupCount + asyncBackupCount; - } - - @Override - public int getSyncBackupCount() { - return 0; - } - - @Override - public Operation getBackupOperation() { - return new SemaphoreDetachMemberBackupOperation(name, detachedMemberUuid); - } - - @Override - public boolean shouldNotify() { - return Boolean.TRUE.equals(response); - } - - @Override - public WaitNotifyKey getNotifiedKey() { - return new SemaphoreWaitNotifyKey(name, "acquire"); - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.DETACH_MEMBER_OPERATION; - } - - @Override - public void writeInternal(ObjectDataOutput out) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public void readInternal(ObjectDataInput in) throws IOException { - throw new UnsupportedOperationException(); - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreOperation.java deleted file mode 100644 index a4e59529d9f74..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreOperation.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.nio.ObjectDataInput; -import com.hazelcast.nio.ObjectDataOutput; -import com.hazelcast.nio.serialization.IdentifiedDataSerializable; -import com.hazelcast.spi.impl.operationservice.PartitionAwareOperation; -import com.hazelcast.spi.impl.operationservice.AbstractNamedOperation; - -import java.io.IOException; - -public abstract class SemaphoreOperation extends AbstractNamedOperation - implements PartitionAwareOperation, IdentifiedDataSerializable { - - protected int permitCount; - protected transient Object response; - - protected SemaphoreOperation() { - } - - protected SemaphoreOperation(String name, int permitCount) { - super(name); - this.permitCount = permitCount; - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public Object getResponse() { - return response; - } - - public SemaphoreContainer getSemaphoreContainer() { - SemaphoreService service = getService(); - return service.getSemaphoreContainer(name); - } - - @Override - public final int getFactoryId() { - return SemaphoreDataSerializerHook.F_ID; - } - - @Override - public void writeInternal(ObjectDataOutput out) throws IOException { - super.writeInternal(out); - out.writeInt(permitCount); - } - - @Override - public void readInternal(ObjectDataInput in) throws IOException { - super.readInternal(in); - permitCount = in.readInt(); - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreReplicationOperation.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreReplicationOperation.java deleted file mode 100644 index 492c65a27bfc9..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/SemaphoreReplicationOperation.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; - -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreContainer; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.nio.ObjectDataInput; -import com.hazelcast.nio.ObjectDataOutput; -import com.hazelcast.nio.serialization.IdentifiedDataSerializable; -import com.hazelcast.spi.impl.operationservice.Operation; - -import java.io.IOException; -import java.util.Map; - -import static com.hazelcast.internal.util.MapUtil.createHashMap; - -public class SemaphoreReplicationOperation extends Operation implements IdentifiedDataSerializable { - - private Map migrationData; - - public SemaphoreReplicationOperation() { - } - - public SemaphoreReplicationOperation(Map migrationData) { - this.migrationData = migrationData; - } - - @Override - public void run() throws Exception { - SemaphoreService service = getService(); - for (SemaphoreContainer semaphoreContainer : migrationData.values()) { - semaphoreContainer.setInitialized(); - } - service.insertMigrationData(migrationData); - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - - @Override - public int getFactoryId() { - return SemaphoreDataSerializerHook.F_ID; - } - - @Override - public int getClassId() { - return SemaphoreDataSerializerHook.SEMAPHORE_REPLICATION_OPERATION; - } - - @Override - protected void writeInternal(ObjectDataOutput out) throws IOException { - out.writeInt(migrationData.size()); - for (Map.Entry entry : migrationData.entrySet()) { - String key = entry.getKey(); - SemaphoreContainer value = entry.getValue(); - out.writeUTF(key); - value.writeData(out); - } - } - - @Override - protected void readInternal(ObjectDataInput in) throws IOException { - int size = in.readInt(); - migrationData = createHashMap(size); - for (int i = 0; i < size; i++) { - String name = in.readUTF(); - SemaphoreContainer semaphoreContainer = new SemaphoreContainer(); - semaphoreContainer.readData(in); - migrationData.put(name, semaphoreContainer); - } - } -} diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/package-info.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/package-info.java deleted file mode 100644 index fea4efe6e58b6..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/operations/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - *

    This package contains the operations on the ISemaphore.
    - * - * @since 2 - */ -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore.operations; diff --git a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/package-info.java b/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/package-info.java deleted file mode 100644 index c418848f9a0ae..0000000000000 --- a/hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/unsafe/semaphore/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - *

    This package contains ISemaphore functionality for Hazelcast.
    - * The ISemaphore is the distributed version of the {@link java.util.concurrent.Semaphore}. - * - * Unfortunately the j.u.c.Semaphore doesn't expose an interface, so the ISemaphore copies most of the - * method and unlike the {@link java.util.concurrent.locks.Lock} the {@link com.hazelcast.cp.ISemaphore} - * is not a drop in replacement for the {@link java.util.concurrent.Semaphore}. - * - * @since 3.2 - */ -package com.hazelcast.cp.internal.datastructures.unsafe.semaphore; diff --git a/hazelcast/src/main/java/com/hazelcast/instance/impl/HazelcastInstanceImpl.java b/hazelcast/src/main/java/com/hazelcast/instance/impl/HazelcastInstanceImpl.java index c5df30adea24f..7ff3e215decc7 100644 --- a/hazelcast/src/main/java/com/hazelcast/instance/impl/HazelcastInstanceImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/instance/impl/HazelcastInstanceImpl.java @@ -34,19 +34,16 @@ import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.HazelcastInstanceAware; import com.hazelcast.core.IExecutorService; -import com.hazelcast.map.IMap; import com.hazelcast.core.IdGenerator; import com.hazelcast.core.ManagedContext; import com.hazelcast.cp.CPSubsystem; import com.hazelcast.cp.IAtomicLong; import com.hazelcast.cp.IAtomicReference; -import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.internal.CPSubsystemImpl; import com.hazelcast.cp.internal.datastructures.unsafe.atomiclong.AtomicLongService; import com.hazelcast.cp.internal.datastructures.unsafe.atomicreference.AtomicReferenceService; import com.hazelcast.cp.internal.datastructures.unsafe.idgen.IdGeneratorService; import com.hazelcast.cp.internal.datastructures.unsafe.lock.LockService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; import com.hazelcast.cp.lock.ILock; import com.hazelcast.crdt.pncounter.PNCounter; import com.hazelcast.crdt.pncounter.PNCounterService; @@ -60,20 +57,21 @@ import com.hazelcast.internal.serialization.InternalSerializationService; import com.hazelcast.logging.ILogger; import com.hazelcast.logging.LoggingService; +import com.hazelcast.map.IMap; import com.hazelcast.map.impl.MapService; import com.hazelcast.memory.MemoryStats; import com.hazelcast.multimap.MultiMap; import com.hazelcast.multimap.impl.MultiMapService; import com.hazelcast.partition.PartitionService; -import com.hazelcast.splitbrainprotection.SplitBrainProtectionService; import com.hazelcast.replicatedmap.ReplicatedMap; import com.hazelcast.replicatedmap.impl.ReplicatedMapService; import com.hazelcast.ringbuffer.Ringbuffer; import com.hazelcast.ringbuffer.impl.RingbufferService; import com.hazelcast.scheduledexecutor.IScheduledExecutorService; import com.hazelcast.scheduledexecutor.impl.DistributedScheduledExecutorService; -import com.hazelcast.spi.impl.proxyservice.ProxyService; import com.hazelcast.spi.impl.SerializationServiceSupport; +import com.hazelcast.spi.impl.proxyservice.ProxyService; +import com.hazelcast.splitbrainprotection.SplitBrainProtectionService; import com.hazelcast.topic.ITopic; import com.hazelcast.topic.impl.TopicService; import com.hazelcast.topic.impl.reliable.ReliableTopicService; @@ -286,12 +284,6 @@ public IAtomicReference getAtomicReference(String name) { return getDistributedObject(AtomicReferenceService.SERVICE_NAME, name); } - @Override - public ISemaphore getSemaphore(String name) { - checkNotNull(name, "Retrieving a semaphore instance with a null name is not allowed!"); - return getDistributedObject(SemaphoreService.SERVICE_NAME, name); - } - @Override public ReplicatedMap getReplicatedMap(String name) { checkNotNull(name, "Retrieving a replicated map instance with a null name is not allowed!"); diff --git a/hazelcast/src/main/java/com/hazelcast/instance/impl/HazelcastInstanceProxy.java b/hazelcast/src/main/java/com/hazelcast/instance/impl/HazelcastInstanceProxy.java index ad70a8ae8b1e5..b0ecbb17cbf0a 100644 --- a/hazelcast/src/main/java/com/hazelcast/instance/impl/HazelcastInstanceProxy.java +++ b/hazelcast/src/main/java/com/hazelcast/instance/impl/HazelcastInstanceProxy.java @@ -30,26 +30,25 @@ import com.hazelcast.core.HazelcastInstanceNotActiveException; import com.hazelcast.core.ICacheManager; import com.hazelcast.core.IExecutorService; -import com.hazelcast.map.IMap; import com.hazelcast.core.IdGenerator; import com.hazelcast.core.LifecycleService; import com.hazelcast.cp.CPSubsystem; import com.hazelcast.cp.IAtomicLong; import com.hazelcast.cp.IAtomicReference; -import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.lock.ILock; import com.hazelcast.crdt.pncounter.PNCounter; import com.hazelcast.durableexecutor.DurableExecutorService; import com.hazelcast.flakeidgen.FlakeIdGenerator; import com.hazelcast.internal.serialization.InternalSerializationService; import com.hazelcast.logging.LoggingService; +import com.hazelcast.map.IMap; import com.hazelcast.multimap.MultiMap; import com.hazelcast.partition.PartitionService; -import com.hazelcast.splitbrainprotection.SplitBrainProtectionService; import com.hazelcast.replicatedmap.ReplicatedMap; import com.hazelcast.ringbuffer.Ringbuffer; import com.hazelcast.scheduledexecutor.IScheduledExecutorService; import com.hazelcast.spi.impl.SerializationServiceSupport; +import com.hazelcast.splitbrainprotection.SplitBrainProtectionService; import com.hazelcast.topic.ITopic; import com.hazelcast.transaction.HazelcastXAResource; import com.hazelcast.transaction.TransactionContext; @@ -190,11 +189,6 @@ public IAtomicReference getAtomicReference(String name) { return getOriginal().getAtomicReference(name); } - @Override - public ISemaphore getSemaphore(String name) { - return getOriginal().getSemaphore(name); - } - @Override public ICacheManager getCacheManager() { return getOriginal().getCacheManager(); diff --git a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/ClusterWideConfigurationService.java b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/ClusterWideConfigurationService.java index a4fd65d505126..be47eb0bf5913 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/ClusterWideConfigurationService.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/ClusterWideConfigurationService.java @@ -37,7 +37,6 @@ import com.hazelcast.config.ReplicatedMapConfig; import com.hazelcast.config.RingbufferConfig; import com.hazelcast.config.ScheduledExecutorConfig; -import com.hazelcast.config.SemaphoreConfig; import com.hazelcast.config.SetConfig; import com.hazelcast.config.TopicConfig; import com.hazelcast.core.HazelcastException; @@ -119,7 +118,6 @@ public class ClusterWideConfigurationService implements PreJoinAwareService, new ConcurrentHashMap(); private final ConcurrentMap scheduledExecutorConfigs = new ConcurrentHashMap(); - private final ConcurrentMap semaphoreConfigs = new ConcurrentHashMap(); private final ConcurrentMap queueConfigs = new ConcurrentHashMap(); private final ConcurrentMap reliableTopicConfigs = new ConcurrentHashMap(); @@ -147,7 +145,6 @@ public class ClusterWideConfigurationService implements PreJoinAwareService, executorConfigs, durableExecutorConfigs, scheduledExecutorConfigs, - semaphoreConfigs, queueConfigs, reliableTopicConfigs, cacheSimpleConfigs, @@ -329,9 +326,6 @@ public void registerConfigLocally(IdentifiedDataSerializable newConfig, if (currentConfig == null) { listener.onConfigRegistered(cacheSimpleConfig); } - } else if (newConfig instanceof SemaphoreConfig) { - SemaphoreConfig semaphoreConfig = (SemaphoreConfig) newConfig; - currentConfig = semaphoreConfigs.putIfAbsent(semaphoreConfig.getName(), semaphoreConfig); } else if (newConfig instanceof FlakeIdGeneratorConfig) { FlakeIdGeneratorConfig config = (FlakeIdGeneratorConfig) newConfig; currentConfig = flakeIdGeneratorConfigs.putIfAbsent(config.getName(), config); @@ -450,16 +444,6 @@ public ConcurrentMap getDurableExecutorConfigs() return durableExecutorConfigs; } - @Override - public SemaphoreConfig findSemaphoreConfig(String name) { - return lookupByPattern(configPatternMatcher, semaphoreConfigs, name); - } - - @Override - public ConcurrentMap getSemaphoreConfigs() { - return semaphoreConfigs; - } - @Override public RingbufferConfig findRingbufferConfig(String name) { return lookupByPattern(configPatternMatcher, ringbufferConfigs, name); @@ -621,7 +605,6 @@ private static Map, Version> initial configToVersion.put(ExecutorConfig.class, V3_9); configToVersion.put(DurableExecutorConfig.class, V3_9); configToVersion.put(ScheduledExecutorConfig.class, V3_9); - configToVersion.put(SemaphoreConfig.class, V3_9); configToVersion.put(QueueConfig.class, V3_9); configToVersion.put(ReliableTopicConfig.class, V3_9); configToVersion.put(CacheSimpleConfig.class, V3_9); diff --git a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/ConfigurationService.java b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/ConfigurationService.java index 68423ff4a067b..c3dfb250b8b80 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/ConfigurationService.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/ConfigurationService.java @@ -34,7 +34,6 @@ import com.hazelcast.config.ReplicatedMapConfig; import com.hazelcast.config.RingbufferConfig; import com.hazelcast.config.ScheduledExecutorConfig; -import com.hazelcast.config.SemaphoreConfig; import com.hazelcast.config.SetConfig; import com.hazelcast.config.TopicConfig; import com.hazelcast.nio.serialization.IdentifiedDataSerializable; @@ -125,14 +124,6 @@ public interface ConfigurationService { */ DurableExecutorConfig findDurableExecutorConfig(String name); - /** - * Finds existing Semaphore config. - * - * @param name name of the config - * @return Semaphore config or {@code null} when requested Semaphore configuration does not exist - */ - SemaphoreConfig findSemaphoreConfig(String name); - /** * Finds existing Ringbuffer config. * @@ -338,13 +329,6 @@ public interface ConfigurationService { */ Map getPNCounterConfigs(); - /** - * Returns all registered semaphore configurations. - * - * @return registered semaphore configurations - */ - Map getSemaphoreConfigs(); - /** * Returns all registered cache configurations. * diff --git a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicCPSubsystemConfig.java b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicCPSubsystemConfig.java index 8fae00e587980..c90664b372b74 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicCPSubsystemConfig.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicCPSubsystemConfig.java @@ -16,7 +16,7 @@ package com.hazelcast.internal.dynamicconfig; -import com.hazelcast.config.cp.CPSemaphoreConfig; +import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.config.cp.RaftAlgorithmConfig; @@ -68,12 +68,12 @@ public CPSubsystemConfig setRaftAlgorithmConfig(RaftAlgorithmConfig raftAlgorith } @Override - public CPSubsystemConfig addSemaphoreConfig(CPSemaphoreConfig cpSemaphoreConfig) { + public CPSubsystemConfig addSemaphoreConfig(SemaphoreConfig semaphoreConfig) { throw new UnsupportedOperationException(); } @Override - public CPSubsystemConfig setSemaphoreConfigs(Map cpSemaphoreConfigs) { + public CPSubsystemConfig setSemaphoreConfigs(Map semaphoreConfigs) { throw new UnsupportedOperationException(); } diff --git a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicConfigurationAwareConfig.java b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicConfigurationAwareConfig.java index fc0410fe1f3b1..bc12c9f18d04d 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicConfigurationAwareConfig.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicConfigurationAwareConfig.java @@ -42,16 +42,15 @@ import com.hazelcast.config.PNCounterConfig; import com.hazelcast.config.PartitionGroupConfig; import com.hazelcast.config.QueueConfig; -import com.hazelcast.config.SplitBrainProtectionConfig; import com.hazelcast.config.ReliableTopicConfig; import com.hazelcast.config.ReplicatedMapConfig; import com.hazelcast.config.RingbufferConfig; import com.hazelcast.config.ScheduledExecutorConfig; import com.hazelcast.config.SecurityConfig; -import com.hazelcast.config.SemaphoreConfig; import com.hazelcast.config.SerializationConfig; import com.hazelcast.config.ServicesConfig; import com.hazelcast.config.SetConfig; +import com.hazelcast.config.SplitBrainProtectionConfig; import com.hazelcast.config.TopicConfig; import com.hazelcast.config.UserCodeDeploymentConfig; import com.hazelcast.config.WanReplicationConfig; @@ -66,8 +65,6 @@ import javax.annotation.Nonnull; import java.io.File; import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Properties; @@ -903,54 +900,6 @@ public Config setPNCounterConfigs(Map pnCounterConfigs) throw new UnsupportedOperationException("Unsupported operation"); } - @Override - public SemaphoreConfig findSemaphoreConfig(String name) { - return getSemaphoreConfigInternal(name, "default").getAsReadOnly(); - } - - @Override - public SemaphoreConfig getSemaphoreConfig(String name) { - return getSemaphoreConfigInternal(name, name); - } - - private SemaphoreConfig getSemaphoreConfigInternal(String name, String fallbackName) { - return (SemaphoreConfig) configSearcher.getConfig(name, fallbackName, supplierFor(SemaphoreConfig.class)); - } - - @Override - public Config addSemaphoreConfig(SemaphoreConfig semaphoreConfig) { - boolean staticConfigDoesNotExist = checkStaticConfigDoesNotExist(staticConfig.getSemaphoreConfigsAsMap(), - semaphoreConfig.getName(), semaphoreConfig); - if (staticConfigDoesNotExist) { - configurationService.broadcastConfig(semaphoreConfig); - } - return this; - } - - @Override - public Collection getSemaphoreConfigs() { - Collection staticConfigs = staticConfig.getSemaphoreConfigs(); - Map semaphoreConfigs = configurationService.getSemaphoreConfigs(); - - ArrayList aggregated = new ArrayList(staticConfigs); - aggregated.addAll(semaphoreConfigs.values()); - - return aggregated; - } - - @Override - public Map getSemaphoreConfigsAsMap() { - Map staticConfigs = staticConfig.getSemaphoreConfigsAsMap(); - Map dynamicConfigs = configurationService.getSemaphoreConfigs(); - - return aggregate(staticConfigs, dynamicConfigs); - } - - @Override - public Config setSemaphoreConfigs(Map semaphoreConfigs) { - throw new UnsupportedOperationException("Unsupported operation"); - } - @Override public Map getFlakeIdGeneratorConfigs() { Map staticMapConfigs = staticConfig.getFlakeIdGeneratorConfigs(); diff --git a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/EmptyConfigurationService.java b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/EmptyConfigurationService.java index 4720dc049eb1d..3e73502868764 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/EmptyConfigurationService.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/EmptyConfigurationService.java @@ -33,7 +33,6 @@ import com.hazelcast.config.ReplicatedMapConfig; import com.hazelcast.config.RingbufferConfig; import com.hazelcast.config.ScheduledExecutorConfig; -import com.hazelcast.config.SemaphoreConfig; import com.hazelcast.config.SetConfig; import com.hazelcast.config.TopicConfig; import com.hazelcast.nio.serialization.IdentifiedDataSerializable; @@ -88,11 +87,6 @@ public DurableExecutorConfig findDurableExecutorConfig(String name) { return null; } - @Override - public SemaphoreConfig findSemaphoreConfig(String name) { - return null; - } - @Override public RingbufferConfig findRingbufferConfig(String name) { return null; @@ -233,11 +227,6 @@ public Map getPNCounterConfigs() { return emptyMap(); } - @Override - public Map getSemaphoreConfigs() { - return emptyMap(); - } - @Override public FlakeIdGeneratorConfig findFlakeIdGeneratorConfig(String baseName) { return null; diff --git a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/search/ConfigSearch.java b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/search/ConfigSearch.java index 8e53c2a219d20..ac91dbab9da7b 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/search/ConfigSearch.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/search/ConfigSearch.java @@ -35,7 +35,6 @@ import com.hazelcast.config.ReplicatedMapConfig; import com.hazelcast.config.RingbufferConfig; import com.hazelcast.config.ScheduledExecutorConfig; -import com.hazelcast.config.SemaphoreConfig; import com.hazelcast.config.SetConfig; import com.hazelcast.config.TopicConfig; import com.hazelcast.internal.dynamicconfig.ConfigurationService; @@ -338,22 +337,6 @@ public Map getStaticConfigs(@Nonnull Config return staticConfig.getCardinalityEstimatorConfigs(); } }); - CONFIG_SUPPLIERS.put(SemaphoreConfig.class, new ConfigSupplier() { - @Override - public SemaphoreConfig getDynamicConfig(@Nonnull ConfigurationService configurationService, @Nonnull String name) { - return configurationService.findSemaphoreConfig(name); - } - - @Override - public SemaphoreConfig getStaticConfig(@Nonnull Config staticConfig, @Nonnull String name) { - return staticConfig.getSemaphoreConfig(name); - } - - @Override - public Map getStaticConfigs(@Nonnull Config staticConfig) { - return staticConfig.getSemaphoreConfigsAsMap(); - } - }); CONFIG_SUPPLIERS.put(FlakeIdGeneratorConfig.class, new ConfigSupplier() { @Override public FlakeIdGeneratorConfig getDynamicConfig(@Nonnull ConfigurationService configurationService, diff --git a/hazelcast/src/main/java/com/hazelcast/internal/jmx/MBeans.java b/hazelcast/src/main/java/com/hazelcast/internal/jmx/MBeans.java index b05062c23493a..0bed5dfac26b3 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/jmx/MBeans.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/jmx/MBeans.java @@ -16,25 +16,23 @@ package com.hazelcast.internal.jmx; +import com.hazelcast.collection.IList; +import com.hazelcast.collection.IQueue; +import com.hazelcast.collection.ISet; import com.hazelcast.collection.impl.list.ListService; import com.hazelcast.collection.impl.queue.QueueService; import com.hazelcast.collection.impl.set.SetService; import com.hazelcast.cp.internal.datastructures.unsafe.atomiclong.AtomicLongService; import com.hazelcast.cp.internal.datastructures.unsafe.atomicreference.AtomicReferenceService; import com.hazelcast.cp.internal.datastructures.unsafe.lock.LockService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; import com.hazelcast.core.DistributedObject; +import com.hazelcast.core.IExecutorService; import com.hazelcast.cp.IAtomicLong; import com.hazelcast.cp.IAtomicReference; -import com.hazelcast.core.IExecutorService; -import com.hazelcast.collection.IList; import com.hazelcast.cp.lock.ILock; import com.hazelcast.executor.impl.DistributedExecutorService; import com.hazelcast.map.IMap; -import com.hazelcast.collection.IQueue; -import com.hazelcast.cp.ISemaphore; import com.hazelcast.topic.ITopic; -import com.hazelcast.collection.ISet; import com.hazelcast.multimap.MultiMap; import com.hazelcast.map.impl.MapService; import com.hazelcast.multimap.impl.MultiMapService; @@ -202,23 +200,6 @@ public String getServiceName() { } }, - SEMAPHORE { - @Override - public HazelcastMBean createNew(DistributedObject distributedObject, ManagementService managementService) { - return new SemaphoreMBean((ISemaphore) distributedObject, managementService); - } - - @Override - public String getObjectType() { - return "ISemaphore"; - } - - @Override - public String getServiceName() { - return SemaphoreService.SERVICE_NAME; - } - }, - EXECUTOR_SERVICE { @Override public HazelcastMBean createNew(DistributedObject distributedObject, ManagementService managementService) { diff --git a/hazelcast/src/main/java/com/hazelcast/osgi/impl/HazelcastOSGiInstanceImpl.java b/hazelcast/src/main/java/com/hazelcast/osgi/impl/HazelcastOSGiInstanceImpl.java index 9eb9558254a6c..1423e87329b97 100644 --- a/hazelcast/src/main/java/com/hazelcast/osgi/impl/HazelcastOSGiInstanceImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/osgi/impl/HazelcastOSGiInstanceImpl.java @@ -35,7 +35,6 @@ import com.hazelcast.cp.CPSubsystem; import com.hazelcast.cp.IAtomicLong; import com.hazelcast.cp.IAtomicReference; -import com.hazelcast.cp.ISemaphore; import com.hazelcast.cp.lock.ILock; import com.hazelcast.crdt.pncounter.PNCounter; import com.hazelcast.durableexecutor.DurableExecutorService; @@ -198,11 +197,6 @@ public IAtomicReference getAtomicReference(String name) { return delegatedInstance.getAtomicReference(name); } - @Override - public ISemaphore getSemaphore(String name) { - return delegatedInstance.getSemaphore(name); - } - @Override public Collection getDistributedObjects() { return delegatedInstance.getDistributedObjects(); diff --git a/hazelcast/src/main/java/com/hazelcast/security/permission/ActionConstants.java b/hazelcast/src/main/java/com/hazelcast/security/permission/ActionConstants.java index 593e254dbd9c2..d80da6e7f37cc 100644 --- a/hazelcast/src/main/java/com/hazelcast/security/permission/ActionConstants.java +++ b/hazelcast/src/main/java/com/hazelcast/security/permission/ActionConstants.java @@ -21,16 +21,15 @@ import com.hazelcast.collection.impl.list.ListService; import com.hazelcast.collection.impl.queue.QueueService; import com.hazelcast.collection.impl.set.SetService; +import com.hazelcast.cp.internal.datastructures.atomiclong.RaftAtomicLongService; +import com.hazelcast.cp.internal.datastructures.atomicref.RaftAtomicRefService; +import com.hazelcast.cp.internal.datastructures.lock.RaftLockService; +import com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreService; import com.hazelcast.cp.internal.datastructures.unsafe.atomiclong.AtomicLongService; import com.hazelcast.cp.internal.datastructures.unsafe.atomicreference.AtomicReferenceService; import com.hazelcast.cp.internal.datastructures.unsafe.idgen.IdGeneratorService; import com.hazelcast.cp.internal.datastructures.unsafe.lock.LockService; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; -import com.hazelcast.cp.internal.datastructures.atomiclong.RaftAtomicLongService; -import com.hazelcast.cp.internal.datastructures.atomicref.RaftAtomicRefService; import com.hazelcast.cp.internal.datastructures.countdownlatch.CountDownLatchService; -import com.hazelcast.cp.internal.datastructures.lock.RaftLockService; -import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService; import com.hazelcast.crdt.pncounter.PNCounterService; import com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService; import com.hazelcast.executor.impl.DistributedExecutorService; @@ -129,12 +128,6 @@ public Permission create(String name, String... actions) { return new SemaphorePermission(name, actions); } }); - PERMISSION_FACTORY_MAP.put(RaftSemaphoreService.SERVICE_NAME, new PermissionFactory() { - @Override - public Permission create(String name, String... actions) { - return new SemaphorePermission(name, actions); - } - }); PERMISSION_FACTORY_MAP.put(TopicService.SERVICE_NAME, new PermissionFactory() { @Override public Permission create(String name, String... actions) { diff --git a/hazelcast/src/main/java/com/hazelcast/spi/impl/servicemanager/impl/ServiceManagerImpl.java b/hazelcast/src/main/java/com/hazelcast/spi/impl/servicemanager/impl/ServiceManagerImpl.java index 2af208575310e..e4c423b12e45b 100644 --- a/hazelcast/src/main/java/com/hazelcast/spi/impl/servicemanager/impl/ServiceManagerImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/spi/impl/servicemanager/impl/ServiceManagerImpl.java @@ -28,7 +28,6 @@ import com.hazelcast.cp.internal.datastructures.unsafe.idgen.IdGeneratorService; import com.hazelcast.cp.internal.datastructures.unsafe.lock.LockService; import com.hazelcast.cp.internal.datastructures.unsafe.lock.LockServiceImpl; -import com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreService; import com.hazelcast.config.ServiceConfig; import com.hazelcast.config.ServicesConfig; import com.hazelcast.core.HazelcastException; @@ -156,7 +155,6 @@ private void registerDefaultServices(ServicesConfig servicesConfig) { registerService(DistributedDurableExecutorService.SERVICE_NAME, new DistributedDurableExecutorService(nodeEngine)); registerService(AtomicLongService.SERVICE_NAME, new AtomicLongService()); registerService(AtomicReferenceService.SERVICE_NAME, new AtomicReferenceService()); - registerService(SemaphoreService.SERVICE_NAME, new SemaphoreService(nodeEngine)); registerService(IdGeneratorService.SERVICE_NAME, new IdGeneratorService(nodeEngine)); registerService(FlakeIdGeneratorService.SERVICE_NAME, new FlakeIdGeneratorService(nodeEngine)); registerService(ReplicatedMapService.SERVICE_NAME, new ReplicatedMapService(nodeEngine)); diff --git a/hazelcast/src/main/resources/META-INF/services/com.hazelcast.DataSerializerHook b/hazelcast/src/main/resources/META-INF/services/com.hazelcast.DataSerializerHook index 333cf4266a590..f60d9f38be9bd 100644 --- a/hazelcast/src/main/resources/META-INF/services/com.hazelcast.DataSerializerHook +++ b/hazelcast/src/main/resources/META-INF/services/com.hazelcast.DataSerializerHook @@ -26,7 +26,6 @@ com.hazelcast.topic.impl.TopicDataSerializerHook com.hazelcast.executor.impl.ExecutorDataSerializerHook com.hazelcast.durableexecutor.impl.DurableExecutorDataSerializerHook com.hazelcast.cp.internal.datastructures.unsafe.lock.LockDataSerializerHook -com.hazelcast.cp.internal.datastructures.unsafe.semaphore.SemaphoreDataSerializerHook com.hazelcast.cp.internal.datastructures.unsafe.atomiclong.AtomicLongDataSerializerHook com.hazelcast.transaction.impl.TransactionDataSerializerHook com.hazelcast.cp.internal.datastructures.unsafe.atomicreference.AtomicReferenceDataSerializerHook @@ -54,7 +53,7 @@ com.hazelcast.cp.internal.session.RaftSessionServiceDataSerializerHook com.hazelcast.cp.internal.datastructures.atomiclong.RaftAtomicLongDataSerializerHook com.hazelcast.cp.internal.datastructures.atomicref.RaftAtomicReferenceDataSerializerHook com.hazelcast.cp.internal.datastructures.lock.RaftLockDataSerializerHook -com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreDataSerializerHook +com.hazelcast.cp.internal.datastructures.semaphore.SemaphoreDataSerializerHook com.hazelcast.cp.internal.datastructures.RaftDataServiceDataSerializerHook com.hazelcast.cp.internal.datastructures.countdownlatch.CountDownLatchDataSerializerHook diff --git a/hazelcast/src/main/resources/hazelcast-config-4.0.xsd b/hazelcast/src/main/resources/hazelcast-config-4.0.xsd index 42609859f096d..73b9ad93e3df5 100644 --- a/hazelcast/src/main/resources/hazelcast-config-4.0.xsd +++ b/hazelcast/src/main/resources/hazelcast-config-4.0.xsd @@ -54,7 +54,6 @@ - @@ -1124,55 +1123,6 @@ - - - - - - The thread count to which the concurrent access is limited. For example, if you set - it to "3", concurrent access to the object is limited to 3 threads. - - - - - - - Number of synchronous backups. For example, if 1 is set as the backup-count, - then all permits of the semaphore are copied to one other JVM for - fail-safety. Valid numbers are 0 (no backup), 1, 2 ... 6. - - - - - - - Number of asynchronous backups. For example, if 1 is set as the backup-count, - then all permits of the semaphore are copied to one other JVM for - fail-safety. Valid numbers are 0 (no backup), 1, 2 ... 6. - - - - - - - Adds the Split Brain Protection for this data-structure which you configure using the split-brain-protection element. - You should set the split-brain-protection-ref's value as the split brain protection's name. - - - - - - - - The name of the semaphore. Required. - - - - - - - - @@ -4465,7 +4415,7 @@ - + @@ -4547,7 +4497,7 @@ - + diff --git a/hazelcast/src/main/resources/hazelcast-default.xml b/hazelcast/src/main/resources/hazelcast-default.xml index 64fd6fc1dff24..4fc1a491711be 100644 --- a/hazelcast/src/main/resources/hazelcast-default.xml +++ b/hazelcast/src/main/resources/hazelcast-default.xml @@ -261,12 +261,6 @@ com.hazelcast.spi.merge.PutIfAbsentMergePolicy - - 0 - 1 - 0 - - 10 BLOCK diff --git a/hazelcast/src/main/resources/hazelcast-default.yaml b/hazelcast/src/main/resources/hazelcast-default.yaml index 1c59b30c8b5a9..6abc63eb1d40d 100644 --- a/hazelcast/src/main/resources/hazelcast-default.yaml +++ b/hazelcast/src/main/resources/hazelcast-default.yaml @@ -250,12 +250,6 @@ hazelcast: batch-size: 100 class-name: com.hazelcast.spi.merge.PutIfAbsentMergePolicy - semaphore: - default: - initial-permits: 0 - backup-count: 1 - async-backup-count: 0 - reliable-topic: default: read-batch-size: 10 diff --git a/hazelcast/src/main/resources/hazelcast-full-example.xml b/hazelcast/src/main/resources/hazelcast-full-example.xml index 07f8940545b73..83020c5f4fb30 100644 --- a/hazelcast/src/main/resources/hazelcast-full-example.xml +++ b/hazelcast/src/main/resources/hazelcast-full-example.xml @@ -1827,31 +1827,6 @@ com.hazelcast.examples.MessageListener - - - 0 - 1 - 0 - splitBrainProtectionRuleWithThreeNodes -