Repository: brooklyn-server Updated Branches: refs/heads/master 5b6bf73a8 -> 48933eb6b
Delete brooklyn-storage-hazelcast This has not been documented, used or recommended ever! It was more experimental, as an approach that might have replaced the existing persisted state approach but never did. Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3c1a7805 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3c1a7805 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3c1a7805 Branch: refs/heads/master Commit: 3c1a7805add0dd584a26b1a0174d8ced44b5c014 Parents: a32cdd6 Author: Aled Sage <[email protected]> Authored: Wed May 3 20:43:23 2017 +0100 Committer: Aled Sage <[email protected]> Committed: Wed May 3 20:46:36 2017 +0100 ---------------------------------------------------------------------- .../deserializingClassRenames.properties | 4 - pom.xml | 2 - storage/hazelcast/pom.xml | 88 --------------- .../storage/impl/hazelcast/EntityId.java | 36 ------- .../impl/hazelcast/EntityStreamSerializer.java | 68 ------------ .../impl/hazelcast/HazelcastDataGrid.java | 89 --------------- .../hazelcast/HazelcastDataGridFactory.java | 42 -------- .../impl/hazelcast/HazelcastStorageTest.java | 107 ------------------- 8 files changed, 436 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c1a7805/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties ---------------------------------------------------------------------- diff --git a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties b/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties index 992d9e5..8a6a7a4 100644 --- a/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties +++ b/core/src/main/resources/org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties @@ -1103,10 +1103,6 @@ brooklyn.entity.webapp.tomcat.TomcatDriver brooklyn.entity.webapp.tomcat.TomcatServer : org.apache.brooklyn.entity.webapp.tomcat.TomcatServer brooklyn.entity.webapp.tomcat.TomcatServerImpl : org.apache.brooklyn.entity.webapp.tomcat.TomcatServerImpl brooklyn.entity.webapp.tomcat.TomcatSshDriver : org.apache.brooklyn.entity.webapp.tomcat.TomcatSshDriver -brooklyn.internal.storage.impl.hazelcast.EntityId : org.apache.brooklyn.internal.storage.impl.hazelcast.EntityId -brooklyn.internal.storage.impl.hazelcast.EntityStreamSerializer : org.apache.brooklyn.internal.storage.impl.hazelcast.EntityStreamSerializer -brooklyn.internal.storage.impl.hazelcast.HazelcastDataGrid : org.apache.brooklyn.internal.storage.impl.hazelcast.HazelcastDataGrid -brooklyn.internal.storage.impl.hazelcast.HazelcastDataGridFactory : org.apache.brooklyn.internal.storage.impl.hazelcast.HazelcastDataGridFactory io.brooklyn.camp.brooklyn.BrooklynCampConstants : org.apache.brooklyn.camp.brooklyn.BrooklynCampConstants io.brooklyn.camp.brooklyn.BrooklynCampPlatform : org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatform io.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherAbstract : org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherAbstract http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c1a7805/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index d2809f3..450e154 100644 --- a/pom.xml +++ b/pom.xml @@ -221,8 +221,6 @@ <module>software/base</module> <module>software/winrm</module> - <module>storage/hazelcast</module> - <module>server-cli</module> <module>launcher-common</module> <module>launcher</module> http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c1a7805/storage/hazelcast/pom.xml ---------------------------------------------------------------------- diff --git a/storage/hazelcast/pom.xml b/storage/hazelcast/pom.xml deleted file mode 100644 index 1017f3c..0000000 --- a/storage/hazelcast/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <artifactId>brooklyn-storage-hazelcast</artifactId> - <packaging>jar</packaging> - <name>Brooklyn Hazelcast Storage</name> - <description> - Provides a Hazelcast implementation of Storage - </description> - - <parent> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-parent</artifactId> - <version>0.12.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION --> - <relativePath>../../parent/pom.xml</relativePath> - </parent> - - <properties> - <hazelcast.version>3.5.4</hazelcast.version> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-utils-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - - <dependency> - <groupId>com.hazelcast</groupId> - <artifactId>hazelcast</artifactId> - <version>${hazelcast.version}</version> - </dependency> - - <!-- test dependencies --> - <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-test-support</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> -<!-- <dependency> - <groupId>org.apache.brooklyn</groupId> - <artifactId>brooklyn-core</artifactId> - <version>${project.version}</version> - <classifier>tests</classifier> - <scope>test</scope> - </dependency> --> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c1a7805/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityId.java ---------------------------------------------------------------------- diff --git a/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityId.java b/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityId.java deleted file mode 100644 index db7f283..0000000 --- a/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityId.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.brooklyn.internal.storage.impl.hazelcast; - -import java.io.Serializable; - -class EntityId implements Serializable { - - private static final long serialVersionUID = 1L; - - private final String id; - - EntityId(String id) { - this.id = id; - } - - String getId() { - return id; - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c1a7805/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java ---------------------------------------------------------------------- diff --git a/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java b/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java deleted file mode 100644 index 5cea12b..0000000 --- a/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.brooklyn.internal.storage.impl.hazelcast; - -import com.hazelcast.nio.ObjectDataInput; -import com.hazelcast.nio.ObjectDataOutput; -import com.hazelcast.nio.serialization.StreamSerializer; - -import java.io.IOException; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.core.objs.proxy.EntityProxyImpl; - -import static java.lang.String.format; - -class EntityStreamSerializer implements StreamSerializer { - - private HazelcastDataGrid hazelcastDataGrid; - - public EntityStreamSerializer(HazelcastDataGrid hazelcastDataGrid) { - this.hazelcastDataGrid = hazelcastDataGrid; - } - - @Override - public Object read(ObjectDataInput in) throws IOException { - EntityId id = in.readObject(); - Entity entity = hazelcastDataGrid.getManagementContext().getEntityManager().getEntity(id.getId()); - if (entity == null) { - throw new IllegalStateException(format("Entity with id [%s] is not found", id)); - } - return java.lang.reflect.Proxy.newProxyInstance( - entity.getClass().getClassLoader(), - entity.getClass().getInterfaces(), - new EntityProxyImpl(entity)); - } - - @Override - public void write(ObjectDataOutput out, Object object) throws IOException { - Entity entity = (Entity) object; - out.writeObject(new EntityId(entity.getId())); - } - - @Override - public int getTypeId() { - return 5000; - } - - @Override - public void destroy() { - //no-op - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c1a7805/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGrid.java ---------------------------------------------------------------------- diff --git a/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGrid.java b/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGrid.java deleted file mode 100644 index 0219f10..0000000 --- a/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGrid.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.brooklyn.internal.storage.impl.hazelcast; - -import java.util.Collections; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentMap; - -import org.apache.brooklyn.api.entity.Entity; -import org.apache.brooklyn.core.internal.storage.DataGrid; -import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal; - -import com.google.common.collect.ImmutableMap; -import com.hazelcast.config.Config; -import com.hazelcast.config.SerializerConfig; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.HazelcastInstanceNotActiveException; - -public class HazelcastDataGrid implements DataGrid { - - private final HazelcastInstance hz; - private final ManagementContextInternal managementContext; - - public HazelcastDataGrid(ManagementContextInternal managementContext, HazelcastInstance hazelcastInstance) { - this.managementContext = managementContext; - if (hazelcastInstance == null) { - Config config = new Config(); - SerializerConfig entitySerializeConfig = new SerializerConfig(); - entitySerializeConfig.setTypeClassName(Entity.class.getName()); - entitySerializeConfig.setImplementation(new EntityStreamSerializer(this)); - config.getSerializationConfig().addSerializerConfig(entitySerializeConfig); - this.hz = Hazelcast.newHazelcastInstance(config); - } else { - this.hz = hazelcastInstance; - } - } - - public ManagementContextInternal getManagementContext() { - return managementContext; - } - - @Override - public <K, V> ConcurrentMap<K, V> getMap(String id) { - return hz.getMap(id); - } - - @Override - public void remove(String id) { - hz.getMap(id).destroy(); - } - - @Override - public void terminate() { - try { - hz.getLifecycleService().shutdown(); - } catch (HazelcastInstanceNotActiveException ignore) { - } - } - - @Override - public Map<String, Object> getDatagridMetrics() { - // TODO would like to have better metrics - return ImmutableMap.<String,Object>of("name", hz.getName(), "isRunning", hz.getLifecycleService().isRunning()); - } - - @Override - public Set<String> getKeys() { - // TODO would like to have all known keys (for tests) - return Collections.emptySet(); - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c1a7805/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGridFactory.java ---------------------------------------------------------------------- diff --git a/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGridFactory.java b/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGridFactory.java deleted file mode 100644 index fa15fc7..0000000 --- a/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGridFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.brooklyn.internal.storage.impl.hazelcast; - -import org.apache.brooklyn.core.internal.storage.DataGrid; -import org.apache.brooklyn.core.internal.storage.DataGridFactory; -import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal; - -import com.hazelcast.core.HazelcastInstance; - -public class HazelcastDataGridFactory implements DataGridFactory { - - private HazelcastInstance hazelcastInstance; - - public HazelcastDataGridFactory() { - } - - public HazelcastDataGridFactory(HazelcastInstance hazelcastInstance) { - this.hazelcastInstance = hazelcastInstance; - } - - @Override - public DataGrid newDataGrid(ManagementContextInternal managementContext) { - return new HazelcastDataGrid(managementContext,hazelcastInstance); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3c1a7805/storage/hazelcast/src/test/java/org/apache/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java ---------------------------------------------------------------------- diff --git a/storage/hazelcast/src/test/java/org/apache/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java b/storage/hazelcast/src/test/java/org/apache/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java deleted file mode 100644 index 4c43e1c..0000000 --- a/storage/hazelcast/src/test/java/org/apache/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.brooklyn.storage.impl.hazelcast; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.List; -import java.util.Map; - -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import org.apache.brooklyn.core.internal.BrooklynProperties; -import org.apache.brooklyn.core.internal.storage.BrooklynStorage; -import org.apache.brooklyn.core.internal.storage.DataGridFactory; -import org.apache.brooklyn.core.internal.storage.Reference; -import org.apache.brooklyn.core.internal.storage.impl.BrooklynStorageImpl; -import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; -import org.apache.brooklyn.internal.storage.impl.hazelcast.HazelcastDataGrid; -import org.apache.brooklyn.internal.storage.impl.hazelcast.HazelcastDataGridFactory; -import org.apache.brooklyn.util.collections.MutableList; - -import com.hazelcast.core.Hazelcast; - -@Test(groups="Integration") -public class HazelcastStorageTest { - - private LocalManagementContext managementContext; - private BrooklynStorage storage; - - @BeforeMethod(alwaysRun = true) - public void setUp() { - BrooklynProperties properties = BrooklynProperties.Factory.newDefault(); - properties.put(DataGridFactory.class.getName(), HazelcastDataGridFactory.class.getName()); - managementContext = new LocalManagementContext(properties); - storage = managementContext.getStorage(); - } - - @AfterMethod(alwaysRun = true) - public void tearDown() { - if (managementContext != null) managementContext.terminate(); - Hazelcast.shutdownAll(); - } - - //test to verify that our HazelcastDatagrid really is being picked up. - @Test - public void testPickUp(){ - assertTrue(storage instanceof BrooklynStorageImpl,"storage should be instance of BrooklynStorageImpl"); - BrooklynStorageImpl brooklynStorageImpl = (BrooklynStorageImpl)storage; - assertTrue(brooklynStorageImpl.getDataGrid() instanceof HazelcastDataGrid,"storage should be instanceof HazelcastDataGrid"); - } - - @Test - public void testGetMap() { - Map<String,String> map = storage.getMap("somemap"); - map.put("foo", "bar"); - assertEquals( map.get("foo"),"bar"); - } - - @Test - public void testGetReference() { - Reference<String> ref = storage.getReference("someReference"); - ref.set("bar"); - assertEquals(ref.get(), "bar"); - } - - @Test - public void testNonConcurrentList(){ - Reference<List<String>> ref = storage.getNonConcurrentList("someReference"); - ref.set(MutableList.of("bar")); - - assertEquals(ref.get().get(0),"bar"); - } - - @Test - public void testRemoveReference(){ - Reference<String> ref = storage.getReference("someReference"); - ref.set("bar"); - storage.remove("someReference"); - assertEquals(ref.get(), null); - } - - @Test - public void testRemoveMap(){ - Map<String,String> map = storage.getMap("somemap"); - map.put("foo", "bar"); - storage.remove("somemap"); - assertEquals(null, map.get("foo")); - } -}
