You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/08/11 04:39:54 UTC
[1/2] incubator-brooklyn git commit: brooklyn-storage-hazelcast: add
org.apache package prefix
Repository: incubator-brooklyn
Updated Branches:
refs/heads/master b7d636103 -> 0dc391191
brooklyn-storage-hazelcast: add org.apache package prefix
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/f867a0d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/f867a0d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/f867a0d9
Branch: refs/heads/master
Commit: f867a0d9d07f993692562a4077cf9bdc26e2d85c
Parents: 2aac052
Author: Ciprian Ciubotariu <ch...@gmx.net>
Authored: Fri Jul 17 12:18:47 2015 +0300
Committer: Ciprian Ciubotariu <ch...@gmx.net>
Committed: Mon Aug 10 11:07:53 2015 +0300
----------------------------------------------------------------------
.../storage/impl/hazelcast/EntityId.java | 36 -------
.../impl/hazelcast/EntityStreamSerializer.java | 67 ------------
.../impl/hazelcast/HazelcastDataGrid.java | 89 ---------------
.../hazelcast/HazelcastDataGridFactory.java | 42 --------
.../storage/impl/hazelcast/EntityId.java | 36 +++++++
.../impl/hazelcast/EntityStreamSerializer.java | 67 ++++++++++++
.../impl/hazelcast/HazelcastDataGrid.java | 89 +++++++++++++++
.../hazelcast/HazelcastDataGridFactory.java | 42 ++++++++
.../impl/hazelcast/HazelcastStorageTest.java | 108 -------------------
.../impl/hazelcast/HazelcastStorageTest.java | 108 +++++++++++++++++++
10 files changed, 342 insertions(+), 342 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f867a0d9/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/EntityId.java
----------------------------------------------------------------------
diff --git a/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/EntityId.java b/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/EntityId.java
deleted file mode 100644
index 2fc9746..0000000
--- a/storage/hazelcast/src/main/java/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 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/incubator-brooklyn/blob/f867a0d9/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java
----------------------------------------------------------------------
diff --git a/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java b/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java
deleted file mode 100644
index be0c80d..0000000
--- a/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java
+++ /dev/null
@@ -1,67 +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 brooklyn.internal.storage.impl.hazelcast;
-
-import brooklyn.entity.Entity;
-import brooklyn.entity.proxying.EntityProxyImpl;
-import com.hazelcast.nio.ObjectDataInput;
-import com.hazelcast.nio.ObjectDataOutput;
-import com.hazelcast.nio.serialization.StreamSerializer;
-
-import java.io.IOException;
-
-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/incubator-brooklyn/blob/f867a0d9/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGrid.java
----------------------------------------------------------------------
diff --git a/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGrid.java b/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGrid.java
deleted file mode 100644
index 5cd19ba..0000000
--- a/storage/hazelcast/src/main/java/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 brooklyn.internal.storage.impl.hazelcast;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import brooklyn.entity.Entity;
-import brooklyn.internal.storage.DataGrid;
-import brooklyn.management.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/incubator-brooklyn/blob/f867a0d9/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGridFactory.java
----------------------------------------------------------------------
diff --git a/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGridFactory.java b/storage/hazelcast/src/main/java/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGridFactory.java
deleted file mode 100644
index 93689cf..0000000
--- a/storage/hazelcast/src/main/java/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 brooklyn.internal.storage.impl.hazelcast;
-
-import brooklyn.internal.storage.DataGrid;
-import brooklyn.internal.storage.DataGridFactory;
-import brooklyn.management.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/incubator-brooklyn/blob/f867a0d9/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
new file mode 100644
index 0000000..db7f283
--- /dev/null
+++ b/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityId.java
@@ -0,0 +1,36 @@
+/*
+ * 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/incubator-brooklyn/blob/f867a0d9/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
new file mode 100644
index 0000000..114cbb4
--- /dev/null
+++ b/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/EntityStreamSerializer.java
@@ -0,0 +1,67 @@
+/*
+ * 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 brooklyn.entity.Entity;
+import brooklyn.entity.proxying.EntityProxyImpl;
+import com.hazelcast.nio.ObjectDataInput;
+import com.hazelcast.nio.ObjectDataOutput;
+import com.hazelcast.nio.serialization.StreamSerializer;
+
+import java.io.IOException;
+
+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/incubator-brooklyn/blob/f867a0d9/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
new file mode 100644
index 0000000..9097c49
--- /dev/null
+++ b/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGrid.java
@@ -0,0 +1,89 @@
+/*
+ * 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 brooklyn.entity.Entity;
+import brooklyn.internal.storage.DataGrid;
+import brooklyn.management.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/incubator-brooklyn/blob/f867a0d9/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
new file mode 100644
index 0000000..004bd16
--- /dev/null
+++ b/storage/hazelcast/src/main/java/org/apache/brooklyn/internal/storage/impl/hazelcast/HazelcastDataGridFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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 brooklyn.internal.storage.DataGrid;
+import brooklyn.internal.storage.DataGridFactory;
+import brooklyn.management.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/incubator-brooklyn/blob/f867a0d9/storage/hazelcast/src/test/java/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java
----------------------------------------------------------------------
diff --git a/storage/hazelcast/src/test/java/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java b/storage/hazelcast/src/test/java/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java
deleted file mode 100644
index 84f2bbc..0000000
--- a/storage/hazelcast/src/test/java/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java
+++ /dev/null
@@ -1,108 +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 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 brooklyn.config.BrooklynProperties;
-import brooklyn.internal.storage.BrooklynStorage;
-import brooklyn.internal.storage.DataGridFactory;
-import brooklyn.internal.storage.Reference;
-import brooklyn.internal.storage.impl.BrooklynStorageImpl;
-import brooklyn.internal.storage.impl.hazelcast.HazelcastDataGrid;
-import brooklyn.internal.storage.impl.hazelcast.HazelcastDataGridFactory;
-import brooklyn.management.internal.LocalManagementContext;
-import 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"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f867a0d9/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
new file mode 100644
index 0000000..426abd5
--- /dev/null
+++ b/storage/hazelcast/src/test/java/org/apache/brooklyn/storage/impl/hazelcast/HazelcastStorageTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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 brooklyn.config.BrooklynProperties;
+import brooklyn.internal.storage.BrooklynStorage;
+import brooklyn.internal.storage.DataGridFactory;
+import brooklyn.internal.storage.Reference;
+import brooklyn.internal.storage.impl.BrooklynStorageImpl;
+import org.apache.brooklyn.internal.storage.impl.hazelcast.HazelcastDataGrid;
+import org.apache.brooklyn.internal.storage.impl.hazelcast.HazelcastDataGridFactory;
+import brooklyn.management.internal.LocalManagementContext;
+import 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"));
+ }
+}
[2/2] incubator-brooklyn git commit: This closes #807
Posted by ha...@apache.org.
This closes #807
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/0dc39119
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/0dc39119
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/0dc39119
Branch: refs/heads/master
Commit: 0dc3911910a6232a490e5d79a008b4968df6c3fe
Parents: b7d6361 f867a0d
Author: Hadrian Zbarcea <ha...@apache.org>
Authored: Mon Aug 10 22:20:22 2015 -0400
Committer: Hadrian Zbarcea <ha...@apache.org>
Committed: Mon Aug 10 22:20:22 2015 -0400
----------------------------------------------------------------------
.../storage/impl/hazelcast/EntityId.java | 36 -------
.../impl/hazelcast/EntityStreamSerializer.java | 67 ------------
.../impl/hazelcast/HazelcastDataGrid.java | 89 ---------------
.../hazelcast/HazelcastDataGridFactory.java | 42 --------
.../storage/impl/hazelcast/EntityId.java | 36 +++++++
.../impl/hazelcast/EntityStreamSerializer.java | 67 ++++++++++++
.../impl/hazelcast/HazelcastDataGrid.java | 89 +++++++++++++++
.../hazelcast/HazelcastDataGridFactory.java | 42 ++++++++
.../impl/hazelcast/HazelcastStorageTest.java | 108 -------------------
.../impl/hazelcast/HazelcastStorageTest.java | 108 +++++++++++++++++++
10 files changed, 342 insertions(+), 342 deletions(-)
----------------------------------------------------------------------