You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:47:50 UTC
[14/51] [abbrv] [partial] brooklyn-library git commit: move subdir
from incubator up a level as it is promoted to its own repo (first
non-incubator commit!)
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGateway.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGateway.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGateway.java
deleted file mode 100644
index 9576549..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGateway.java
+++ /dev/null
@@ -1,75 +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.entity.nosql.couchbase;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-@ImplementedBy(CouchbaseSyncGatewayImpl.class)
-public interface CouchbaseSyncGateway extends SoftwareProcess {
-
- @SetFromFlag("version")
- ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION,
- "1.0-beta3.1");
-
- @SetFromFlag("downloadUrl")
- BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new BasicAttributeSensorAndConfigKey<String>(
- SoftwareProcess.DOWNLOAD_URL, "http://packages.couchbase.com/releases/couchbase-sync-gateway/1.0-beta/couchbase-sync-gateway-community_${version}_${driver.osTag}");
-
- @SetFromFlag("couchbaseServer")
- ConfigKey<Entity> COUCHBASE_SERVER = ConfigKeys.newConfigKey(Entity.class, "couchbaseSyncGateway.couchbaseNode",
- "Couchbase server node or cluster the sync gateway connects to");
-
- @SetFromFlag("serverPool")
- ConfigKey<String> COUCHBASE_SERVER_POOL = ConfigKeys.newStringConfigKey("couchbaseSyncGateway.serverPool",
- "Couchbase Server pool name in which to find buckets", "default");
-
- @SetFromFlag("couchbaseServerBucket")
- ConfigKey<String> COUCHBASE_SERVER_BUCKET = ConfigKeys.newStringConfigKey("couchbaseSyncGateway.serverBucket",
- "Name of the Couchbase bucket to use", "sync_gateway");
-
- @SetFromFlag("pretty")
- ConfigKey<Boolean> PRETTY = ConfigKeys.newBooleanConfigKey("couchbaseSyncGateway.pretty",
- "Pretty-print JSON responses. This is useful for debugging, but reduces performance.", false);
-
- @SetFromFlag("verbose")
- ConfigKey<Boolean> VERBOSE = ConfigKeys.newBooleanConfigKey("couchbaseSyncGateway.verbose",
- "Logs more information about requests.", false);
-
- AttributeSensor<String> COUCHBASE_SERVER_WEB_URL = Sensors.newStringSensor("couchbaseSyncGateway.serverWebUrl",
- "The Url and web port of the couchbase server to connect to");
-
- AttributeSensor<String> MANAGEMENT_URL = Sensors.newStringSensor("coucbaseSyncGateway.managementUrl",
- "Management URL for Couchbase Sycn Gateway");
-
- PortAttributeSensorAndConfigKey SYNC_REST_API_PORT = new PortAttributeSensorAndConfigKey("couchbaseSyncGateway.syncRestPort",
- "Port the Sync REST API listens on", "4984");
-
- PortAttributeSensorAndConfigKey ADMIN_REST_API_PORT = new PortAttributeSensorAndConfigKey("couchbaseSyncGateway.adminRestPort",
- "Port the Admin REST API listens on", "4985");
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayDriver.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayDriver.java
deleted file mode 100644
index 1b29e9f..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayDriver.java
+++ /dev/null
@@ -1,27 +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.entity.nosql.couchbase;
-
-import org.apache.brooklyn.entity.software.base.SoftwareProcessDriver;
-
-public interface CouchbaseSyncGatewayDriver extends SoftwareProcessDriver {
-
- public String getOsTag();
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayImpl.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayImpl.java
deleted file mode 100644
index 0b42c76..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayImpl.java
+++ /dev/null
@@ -1,82 +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.entity.nosql.couchbase;
-
-import org.apache.brooklyn.core.config.render.RendererHints;
-import org.apache.brooklyn.core.location.access.BrooklynAccessUtils;
-import org.apache.brooklyn.entity.software.base.SoftwareProcessImpl;
-import org.apache.brooklyn.feed.http.HttpFeed;
-import org.apache.brooklyn.feed.http.HttpPollConfig;
-import org.apache.brooklyn.feed.http.HttpValueFunctions;
-
-import com.google.common.base.Functions;
-import com.google.common.net.HostAndPort;
-
-public class CouchbaseSyncGatewayImpl extends SoftwareProcessImpl implements CouchbaseSyncGateway {
-
- private HttpFeed httpFeed;
-
- @Override
- public Class<CouchbaseSyncGatewayDriver> getDriverInterface() {
- return CouchbaseSyncGatewayDriver.class;
- }
-
- @Override
- protected void connectSensors() {
- super.connectSensors();
- connectServiceUpIsRunning();
- }
-
- @Override
- protected void connectServiceUpIsRunning() {
- HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this,
- getAttribute(CouchbaseSyncGateway.ADMIN_REST_API_PORT));
-
- String managementUri = String.format("http://%s:%s",
- hp.getHostText(), hp.getPort());
-
- sensors().set(MANAGEMENT_URL, managementUri);
-
- httpFeed = HttpFeed.builder()
- .entity(this)
- .period(200)
- .baseUri(managementUri)
- .poll(new HttpPollConfig<Boolean>(SERVICE_UP)
- .onSuccess(HttpValueFunctions.responseCodeEquals(200))
- .onFailureOrException(Functions.constant(false)))
- .build();
- }
-
- @Override
- protected void disconnectSensors() {
- super.disconnectSensors();
- disconnectServiceUpIsRunning();
- }
-
- @Override
- protected void disconnectServiceUpIsRunning() {
- if (httpFeed != null) {
- httpFeed.stop();
- }
- }
-
- static {
- RendererHints.register(MANAGEMENT_URL, RendererHints.namedActionWithUrl());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewaySshDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewaySshDriver.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewaySshDriver.java
deleted file mode 100644
index 8a5a25e..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewaySshDriver.java
+++ /dev/null
@@ -1,167 +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.entity.nosql.couchbase;
-
-import static java.lang.String.format;
-import static org.apache.brooklyn.util.ssh.BashCommands.INSTALL_CURL;
-import static org.apache.brooklyn.util.ssh.BashCommands.alternatives;
-import static org.apache.brooklyn.util.ssh.BashCommands.chainGroup;
-import static org.apache.brooklyn.util.ssh.BashCommands.sudo;
-
-import java.util.List;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
-import org.apache.brooklyn.api.entity.drivers.downloads.DownloadResolver;
-import org.apache.brooklyn.api.location.OsDetails;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.EntityPredicates;
-import org.apache.brooklyn.core.sensor.DependentConfiguration;
-import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.ssh.BashCommands;
-import org.apache.brooklyn.util.time.Duration;
-import org.apache.brooklyn.util.time.Time;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-
-public class CouchbaseSyncGatewaySshDriver extends AbstractSoftwareProcessSshDriver implements CouchbaseSyncGatewayDriver {
- public CouchbaseSyncGatewaySshDriver(EntityLocal entity, SshMachineLocation machine) {
- super(entity, machine);
- }
-
- @Override
- public void stop() {
-
- }
-
- @Override
- public void install() {
- //reference http://docs.couchbase.com/sync-gateway/#getting-started-with-sync-gateway
- DownloadResolver resolver = Entities.newDownloader(this);
- List<String> urls = resolver.getTargets();
- String saveAs = resolver.getFilename();
-
- OsDetails osDetails = getMachine().getMachineDetails().getOsDetails();
-
- log.info("Installing couchbase-sync-gateway version: {}", getVersion());
- if (osDetails.isLinux()) {
- List<String> commands = installLinux(urls, saveAs);
- newScript(INSTALLING)
- .body.append(commands).execute();
- }
- }
-
- @Override
- public void customize() {
-
- }
-
- @Override
- public void launch() {
- Entity cbNode = entity.getConfig(CouchbaseSyncGateway.COUCHBASE_SERVER);
- Entities.waitForServiceUp(cbNode, Duration.ONE_HOUR);
- DependentConfiguration.waitInTaskForAttributeReady(cbNode, CouchbaseCluster.IS_CLUSTER_INITIALIZED, Predicates.equalTo(true));
- // Even once the bucket has published its API URL, it can still take a couple of seconds for it to become available
- Time.sleep(10 * 1000);
- if (cbNode instanceof CouchbaseCluster) {
- // in_cluster now applies even to a node in a cluster of size 1
- Optional<Entity> cbClusterNode = Iterables.tryFind(cbNode.getAttribute(CouchbaseCluster.GROUP_MEMBERS),
- Predicates.and(Predicates.instanceOf(CouchbaseNode.class), EntityPredicates.attributeEqualTo(CouchbaseNode.IS_IN_CLUSTER, Boolean.TRUE)));
-
- if (!cbClusterNode.isPresent()) {
- throw new IllegalArgumentException(format("The cluster %s does not contain any suitable Couchbase nodes to connect to..", cbNode.getId()));
- }
-
- cbNode = cbClusterNode.get();
- }
- String hostname = cbNode.getAttribute(CouchbaseNode.HOSTNAME);
- String webPort = cbNode.getAttribute(CouchbaseNode.COUCHBASE_WEB_ADMIN_PORT).toString();
-
-
- String username = cbNode.getConfig(CouchbaseNode.COUCHBASE_ADMIN_USERNAME);
- String password = cbNode.getConfig(CouchbaseNode.COUCHBASE_ADMIN_PASSWORD);
-
- String bucketName = entity.getConfig(CouchbaseSyncGateway.COUCHBASE_SERVER_BUCKET);
- String pool = entity.getConfig(CouchbaseSyncGateway.COUCHBASE_SERVER_POOL);
- String pretty = entity.getConfig(CouchbaseSyncGateway.PRETTY) ? "-pretty" : "";
- String verbose = entity.getConfig(CouchbaseSyncGateway.VERBOSE) ? "-verbose" : "";
-
- String adminRestApiPort = entity.getConfig(CouchbaseSyncGateway.ADMIN_REST_API_PORT).iterator().next().toString();
- String syncRestApiPort = entity.getConfig(CouchbaseSyncGateway.SYNC_REST_API_PORT).iterator().next().toString();
-
- String serverWebAdminUrl = format("http://%s:%s@%s:%s", username, password, hostname, webPort);
- String options = format("-url %s -bucket %s -adminInterface 0.0.0.0:%s -interface 0.0.0.0:%s -pool %s %s %s",
- serverWebAdminUrl, bucketName, adminRestApiPort, syncRestApiPort, pool, pretty, verbose);
-
- newScript(ImmutableMap.of("usePidFile", true), LAUNCHING)
- .body.append(format("/opt/couchbase-sync-gateway/bin/sync_gateway %s ", options) + "> out.log 2> err.log < /dev/null &")
- .failOnNonZeroResultCode()
- .execute();
- }
-
- @Override
- public boolean isRunning() {
- return newScript(MutableMap.of("usePidFile", true), CHECK_RUNNING).execute() == 0;
- }
-
- @Override
- public void kill() {
- newScript(MutableMap.of("usePidFile", true), KILLING).execute();
- }
-
- private List<String> installLinux(List<String> urls, String saveAs) {
-
- String apt = chainGroup(
- "which apt-get",
- sudo("apt-get update"),
- sudo(format("dpkg -i %s", saveAs)));
-
- String yum = chainGroup(
- "which yum",
- sudo(format("rpm --install %s", saveAs)));
-
- return ImmutableList.<String>builder()
- .add(INSTALL_CURL)
- .addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs))
- .add(alternatives(apt, yum))
- .build();
- }
-
- @Override
- public String getOsTag() {
- OsDetails os = getLocation().getOsDetails();
- if (os == null) {
- // Default to generic linux
- return "x86_64.rpm";
- } else {
- //FIXME should be a better way to check for OS name and version
- String osName = os.getName().toLowerCase();
- String fileExtension = osName.contains("deb") || osName.contains("ubuntu") ? ".deb" : ".rpm";
- String arch = os.is64bit() ? "x86_64" : "x86";
- return arch + fileExtension;
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBCluster.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBCluster.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBCluster.java
deleted file mode 100644
index c341945..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBCluster.java
+++ /dev/null
@@ -1,48 +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.entity.nosql.couchdb;
-
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.entity.group.DynamicCluster;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-/**
- * A cluster of {@link CouchDBNode}s based on {@link DynamicCluster} which can be resized by a policy if required.
- *
- * TODO add sensors with aggregated CouchDB statistics from cluster
- */
-@ImplementedBy(CouchDBClusterImpl.class)
-public interface CouchDBCluster extends DynamicCluster {
-
- @SetFromFlag("clusterName")
- BasicAttributeSensorAndConfigKey<String> CLUSTER_NAME = new BasicAttributeSensorAndConfigKey<String>(String.class, "couchdb.cluster.name", "Name of the CouchDB cluster", "BrooklynCluster");
-
- AttributeSensor<String> HOSTNAME = Sensors.newStringSensor("couchdb.cluster.hostname", "Hostname to connect to cluster with");
-
- AttributeSensor<Integer> HTTP_PORT = Sensors.newIntegerSensor("couchdb.cluster.http.port", "CouchDB HTTP port to connect to cluster with");
-
- /**
- * The name of the cluster.
- */
- String getClusterName();
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBClusterImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBClusterImpl.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBClusterImpl.java
deleted file mode 100644
index 84f64f2..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBClusterImpl.java
+++ /dev/null
@@ -1,50 +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.entity.nosql.couchdb;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.entity.group.DynamicClusterImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of {@link CouchDBCluster}.
- */
-public class CouchDBClusterImpl extends DynamicClusterImpl implements CouchDBCluster {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(CouchDBClusterImpl.class);
-
- public CouchDBClusterImpl() {
- }
-
- /**
- * Sets the default {@link #MEMBER_SPEC} to describe the CouchDB nodes.
- */
- @Override
- protected EntitySpec<?> getMemberSpec() {
- return getConfig(MEMBER_SPEC, EntitySpec.create(CouchDBNode.class));
- }
-
- @Override
- public String getClusterName() {
- return getAttribute(CLUSTER_NAME);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNode.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNode.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNode.java
deleted file mode 100644
index fa9506a..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNode.java
+++ /dev/null
@@ -1,66 +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.entity.nosql.couchdb;
-
-import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.entity.webapp.WebAppService;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-/**
- * An {@link org.apache.brooklyn.api.entity.Entity} that represents a CouchDB node in a {@link CouchDBCluster}.
- */
-@Catalog(name="CouchDB Node",
- description="Apache CouchDB is a database that uses JSON for documents, JavaScript for MapReduce queries, " +
- "and regular HTTP for an API",
- iconUrl="classpath:///couchdb-logo.png")
-@ImplementedBy(CouchDBNodeImpl.class)
-public interface CouchDBNode extends SoftwareProcess, WebAppService {
-
- @SetFromFlag("version")
- ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "1.2.1");
-
- @SetFromFlag("erlangVersion")
- ConfigKey<String> ERLANG_VERSION = ConfigKeys.newStringConfigKey("erlang.version", "Erlang runtime version", "R15B");
-
- @SetFromFlag("clusterName")
- BasicAttributeSensorAndConfigKey<String> CLUSTER_NAME = CouchDBCluster.CLUSTER_NAME;
-
- @SetFromFlag("couchdbConfigTemplateUrl")
- BasicAttributeSensorAndConfigKey<String> COUCHDB_CONFIG_TEMPLATE_URL = new BasicAttributeSensorAndConfigKey<String>(
- String.class, "couchdb.config.templateUrl", "Template file (in freemarker format) for the couchdb config file",
- "classpath://org/apache/brooklyn/entity/nosql/couchdb/couch.ini");
-
- @SetFromFlag("couchdbUriTemplateUrl")
- BasicAttributeSensorAndConfigKey<String> COUCHDB_URI_TEMPLATE_URL = new BasicAttributeSensorAndConfigKey<String>(
- String.class, "couchdb.uri.templateUrl", "Template file (in freemarker format) for the couchdb URI file",
- "classpath://org/apache/brooklyn/entity/nosql/couchdb/couch.uri");
-
- @SetFromFlag("couchdbConfigFileName")
- BasicAttributeSensorAndConfigKey<String> COUCHDB_CONFIG_FILE_NAME = new BasicAttributeSensorAndConfigKey<String>(
- String.class, "couchdb.config.fileName", "Name for the copied config file", "local.ini");
-
- Integer getHttpPort();
-
- Integer getHttpsPort();
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeDriver.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeDriver.java
deleted file mode 100644
index 59a04b9..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeDriver.java
+++ /dev/null
@@ -1,37 +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.entity.nosql.couchdb;
-
-import org.apache.brooklyn.entity.software.base.SoftwareProcessDriver;
-
-public interface CouchDBNodeDriver extends SoftwareProcessDriver {
-
- Integer getHttpPort();
-
- Integer getHttpsPort();
-
- String getClusterName();
-
- String getCouchDBConfigTemplateUrl();
-
- String getCouchDBUriTemplateUrl();
-
- String getCouchDBConfigFileName();
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeImpl.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeImpl.java
deleted file mode 100644
index 933e818..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeImpl.java
+++ /dev/null
@@ -1,109 +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.entity.nosql.couchdb;
-
-import java.util.concurrent.TimeUnit;
-
-import javax.annotation.Nullable;
-
-import org.apache.brooklyn.core.entity.EntityFunctions;
-import org.apache.brooklyn.entity.software.base.SoftwareProcessImpl;
-import org.apache.brooklyn.entity.webapp.JavaWebAppSoftwareProcessImpl;
-import org.apache.brooklyn.entity.webapp.WebAppServiceMethods;
-import org.apache.brooklyn.feed.http.HttpFeed;
-import org.apache.brooklyn.feed.http.HttpPollConfig;
-import org.apache.brooklyn.feed.http.HttpValueFunctions;
-import org.apache.brooklyn.util.core.flags.TypeCoercions;
-import org.apache.brooklyn.util.guava.Functionals;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
-import com.google.common.base.Functions;
-
-/**
- * Implementation of {@link CouchDBNode}.
- */
-public class CouchDBNodeImpl extends SoftwareProcessImpl implements CouchDBNode {
-
- private static final Logger log = LoggerFactory.getLogger(CouchDBNodeImpl.class);
-
- public CouchDBNodeImpl() {
- }
-
- public Integer getHttpPort() { return getAttribute(CouchDBNode.HTTP_PORT); }
- public Integer getHttpsPort() { return getAttribute(CouchDBNode.HTTPS_PORT); }
- public String getClusterName() { return getAttribute(CouchDBNode.CLUSTER_NAME); }
-
- @Override
- public Class<CouchDBNodeDriver> getDriverInterface() {
- return CouchDBNodeDriver.class;
- }
-
- private volatile HttpFeed httpFeed;
-
- @Override
- protected void connectSensors() {
- super.connectSensors();
-
- connectServiceUpIsRunning();
-
- boolean retrieveUsageMetrics = getConfig(RETRIEVE_USAGE_METRICS);
-
- httpFeed = HttpFeed.builder()
- .entity(this)
- .period(500, TimeUnit.MILLISECONDS)
- .baseUri(String.format("http://%s:%d/_stats", getAttribute(HOSTNAME), getHttpPort()))
- .poll(new HttpPollConfig<Integer>(REQUEST_COUNT)
- .onSuccess(HttpValueFunctions.jsonContents(new String[] { "httpd", "requests", "count" }, Integer.class))
- .onFailureOrException(EntityFunctions.attribute(this, REQUEST_COUNT))
- .enabled(retrieveUsageMetrics))
- .poll(new HttpPollConfig<Integer>(ERROR_COUNT)
- .onSuccess(HttpValueFunctions.jsonContents(new String[] { "httpd_status_codes", "404", "count" }, Integer.class))
- .onFailureOrException(Functions.constant(-1))
- .enabled(retrieveUsageMetrics))
- .poll(new HttpPollConfig<Integer>(TOTAL_PROCESSING_TIME)
- .onSuccess(HttpValueFunctions.jsonContents(new String[] { "couchdb", "request_time", "count" }, Integer.class))
- .onFailureOrException(Functions.constant(-1))
- .enabled(retrieveUsageMetrics))
- .poll(new HttpPollConfig<Integer>(MAX_PROCESSING_TIME)
- .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(new String[] { "couchdb", "request_time", "max" }, Double.class), TypeCoercions.function(Integer.class)))
- .onFailureOrException(Functions.constant(-1))
- .enabled(retrieveUsageMetrics))
- .build();
-
- WebAppServiceMethods.connectWebAppServerPolicies(this);
- }
-
- @Override
- public void disconnectSensors() {
- super.disconnectSensors();
- if (httpFeed != null) httpFeed.stop();
- disconnectServiceUpIsRunning();
- }
-
- /** @see JavaWebAppSoftwareProcessImpl#postStop() */
- @Override
- protected void postStop() {
- super.postStop();
- // zero our workrate derived workrates.
- sensors().set(REQUESTS_PER_SECOND_LAST, 0D);
- sensors().set(REQUESTS_PER_SECOND_IN_WINDOW, 0D);
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeSshDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeSshDriver.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeSshDriver.java
deleted file mode 100644
index 60c1f84..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeSshDriver.java
+++ /dev/null
@@ -1,152 +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.entity.nosql.couchdb;
-
-import static org.apache.brooklyn.util.ssh.BashCommands.*;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.net.Networking;
-import org.apache.brooklyn.util.os.Os;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Sets;
-
-/**
- * Start a {@link CouchDBNode} in a {@link Location} accessible over ssh.
- */
-public class CouchDBNodeSshDriver extends AbstractSoftwareProcessSshDriver implements CouchDBNodeDriver {
-
- private static final Logger log = LoggerFactory.getLogger(CouchDBNodeSshDriver.class);
-
- public CouchDBNodeSshDriver(CouchDBNodeImpl entity, SshMachineLocation machine) {
- super(entity, machine);
-
- entity.sensors().set(Attributes.LOG_FILE_LOCATION, getLogFileLocation());
- }
-
- public String getLogFileLocation() { return Os.mergePathsUnix(getRunDir(), "couchdb.log"); }
-
- @Override
- public Integer getHttpPort() { return entity.getAttribute(CouchDBNode.HTTP_PORT); }
-
- @Override
- public Integer getHttpsPort() { return entity.getAttribute(CouchDBNode.HTTPS_PORT); }
-
- @Override
- public String getClusterName() { return entity.getAttribute(CouchDBNode.CLUSTER_NAME); }
-
- @Override
- public String getCouchDBConfigTemplateUrl() { return entity.getAttribute(CouchDBNode.COUCHDB_CONFIG_TEMPLATE_URL); }
-
- @Override
- public String getCouchDBUriTemplateUrl() { return entity.getAttribute(CouchDBNode.COUCHDB_URI_TEMPLATE_URL); }
-
- @Override
- public String getCouchDBConfigFileName() { return entity.getAttribute(CouchDBNode.COUCHDB_CONFIG_FILE_NAME); }
-
- public String getErlangVersion() { return entity.getConfig(CouchDBNode.ERLANG_VERSION); }
-
- @Override
- public void install() {
- log.info("Installing {}", entity);
- List<String> commands = ImmutableList.<String>builder()
- .add(ifExecutableElse0("zypper", chainGroup( // SLES 11 not supported, would require building from source
- ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/devel:/languages:/erlang/openSUSE_11.4 erlang_suse_11")),
- ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/devel:/languages:/erlang/openSUSE_12.3 erlang_suse_12")),
- ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/devel:/languages:/erlang/openSUSE_13.1 erlang_suse_13")),
- ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/server:/database/openSUSE_11.4 db_suse_11")),
- ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/server:/database/openSUSE_12.3 db_suse_12")),
- ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/server:/database/openSUSE_13.1 db_suse_13")))))
- .add(installPackage( // NOTE only 'port' states the version of Erlang used, maybe remove this constraint?
- ImmutableMap.of(
- "apt", "erlang-nox erlang-dev",
- "port", "erlang@"+getErlangVersion()+"+ssl"),
- "erlang"))
- .add(installPackage("couchdb"))
- .add(ifExecutableElse0("service", sudo("service couchdb stop")))
- .build();
-
- newScript(INSTALLING)
- .body.append(commands)
- .execute();
- }
-
- @Override
- public Set<Integer> getPortsUsed() {
- Set<Integer> result = Sets.newLinkedHashSet(super.getPortsUsed());
- result.addAll(getPortMap().values());
- return result;
- }
-
- private Map<String, Integer> getPortMap() {
- return ImmutableMap.<String, Integer>builder()
- .put("httpPort", getHttpPort())
- .build();
- }
-
- @Override
- public void customize() {
- log.info("Customizing {} (Cluster {})", entity, getClusterName());
- Networking.checkPortsValid(getPortMap());
-
- newScript(CUSTOMIZING).execute();
-
- // Copy the configuration files across
- String destinationConfigFile = Os.mergePathsUnix(getRunDir(), getCouchDBConfigFileName());
- copyTemplate(getCouchDBConfigTemplateUrl(), destinationConfigFile);
- String destinationUriFile = Os.mergePathsUnix(getRunDir(), "couch.uri");
- copyTemplate(getCouchDBUriTemplateUrl(), destinationUriFile);
- }
-
- @Override
- public void launch() {
- log.info("Launching {}", entity);
- newScript(MutableMap.of(USE_PID_FILE, false), LAUNCHING)
- .body.append(sudo(String.format("nohup couchdb -p %s -a %s -o couchdb-console.log -e couchdb-error.log -b &", getPidFile(), Os.mergePathsUnix(getRunDir(), getCouchDBConfigFileName()))))
- .execute();
- }
-
- public String getPidFile() { return Os.mergePathsUnix(getRunDir(), "couchdb.pid"); }
-
- @Override
- public boolean isRunning() {
- return newScript(MutableMap.of(USE_PID_FILE, false), CHECK_RUNNING)
- .body.append(sudo(String.format("couchdb -p %s -s", getPidFile())))
- .execute() == 0;
- }
-
- @Override
- public void stop() {
- newScript(MutableMap.of(USE_PID_FILE, false), STOPPING)
- .body.append(sudo(String.format("couchdb -p %s -k", getPidFile())))
- .failOnNonZeroResultCode()
- .execute();
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchCluster.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchCluster.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchCluster.java
deleted file mode 100644
index e0fbc7e..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchCluster.java
+++ /dev/null
@@ -1,40 +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.entity.nosql.elasticsearch;
-
-import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.entity.group.DynamicCluster;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-/**
- * A cluster of {@link ElasticSearchNode}s based on {@link DynamicCluster} which can be resized by a policy if required.
- */
-@Catalog(name="Elastic Search Cluster", description="Elasticsearch is an open-source search server based on Lucene. "
- + "It provides a distributed, multitenant-capable full-text search engine with a RESTful web interface and "
- + "schema-free JSON documents.")
-@ImplementedBy(ElasticSearchClusterImpl.class)
-public interface ElasticSearchCluster extends DynamicCluster {
- @SetFromFlag("clusterName")
- BasicAttributeSensorAndConfigKey<String> CLUSTER_NAME = new BasicAttributeSensorAndConfigKey<String>(String.class,
- "elasticsearch.cluster.name", "Name of the ElasticSearch cluster", "BrooklynCluster");
-
- String getClusterName();
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterImpl.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterImpl.java
deleted file mode 100644
index 58c6c23..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterImpl.java
+++ /dev/null
@@ -1,45 +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.entity.nosql.elasticsearch;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.entity.group.DynamicClusterImpl;
-
-public class ElasticSearchClusterImpl extends DynamicClusterImpl implements ElasticSearchCluster {
-
- private AtomicInteger nextMemberId = new AtomicInteger(0);
-
- @Override
- protected EntitySpec<?> getMemberSpec() {
- EntitySpec<?> spec = EntitySpec.create(getConfig(MEMBER_SPEC, EntitySpec.create(ElasticSearchNode.class)));
-
- spec.configure(ElasticSearchNode.CLUSTER_NAME, getConfig(ElasticSearchClusterImpl.CLUSTER_NAME))
- .configure(ElasticSearchNode.NODE_NAME, "elasticsearch-" + nextMemberId.incrementAndGet());
-
- return spec;
- }
-
- @Override
- public String getClusterName() {
- return getConfig(CLUSTER_NAME);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNode.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNode.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNode.java
deleted file mode 100644
index 1687bf1..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNode.java
+++ /dev/null
@@ -1,93 +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.entity.nosql.elasticsearch;
-
-import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.location.PortRanges;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey.StringAttributeSensorAndConfigKey;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.entity.webapp.WebAppServiceConstants;
-import org.apache.brooklyn.entity.database.DatastoreMixins;
-import org.apache.brooklyn.util.core.ResourcePredicates;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-/**
- * An {@link org.apache.brooklyn.api.entity.Entity} that represents an ElasticSearch node
- */
-@Catalog(name="Elastic Search Node", description="Elasticsearch is an open-source search server based on Lucene. "
- + "It provides a distributed, multitenant-capable full-text search engine with a RESTful web interface and "
- + "schema-free JSON documents.")
-@ImplementedBy(ElasticSearchNodeImpl.class)
-public interface ElasticSearchNode extends SoftwareProcess, DatastoreMixins.HasDatastoreUrl {
- @SetFromFlag("version")
- ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "1.2.1");
-
- @SetFromFlag("downloadUrl")
- BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new BasicAttributeSensorAndConfigKey<String>(
- SoftwareProcess.DOWNLOAD_URL, "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${version}.tar.gz");
-
- @SetFromFlag("dataDir")
- ConfigKey<String> DATA_DIR = ConfigKeys.newStringConfigKey("elasticsearch.node.data.dir", "Directory for writing data files", null);
-
- @SetFromFlag("logDir")
- ConfigKey<String> LOG_DIR = ConfigKeys.newStringConfigKey("elasticsearch.node.log.dir", "Directory for writing log files", null);
-
- @SetFromFlag("configFileUrl")
- ConfigKey<String> TEMPLATE_CONFIGURATION_URL = ConfigKeys.builder(String.class)
- .name("elasticsearch.node.template.configuration.url")
- .description("URL where the elasticsearch configuration file (in freemarker format) can be found")
- .defaultValue(null)
- .constraint(ResourcePredicates.urlIsBlankOrExists())
- .build();
-
- @SetFromFlag("multicastEnabled")
- ConfigKey<Boolean> MULTICAST_ENABLED = ConfigKeys.newBooleanConfigKey("elasticsearch.node.multicast.enabled",
- "Indicates whether zen discovery multicast should be enabled for a node", null);
-
- @SetFromFlag("multicastEnabled")
- ConfigKey<Boolean> UNICAST_ENABLED = ConfigKeys.newBooleanConfigKey("elasticsearch.node.UNicast.enabled",
- "Indicates whether zen discovery unicast should be enabled for a node", null);
-
- @SetFromFlag("httpPort")
- PortAttributeSensorAndConfigKey HTTP_PORT = new PortAttributeSensorAndConfigKey(WebAppServiceConstants.HTTP_PORT, PortRanges.fromString("9200+"));
-
- @SetFromFlag("nodeName")
- StringAttributeSensorAndConfigKey NODE_NAME = new StringAttributeSensorAndConfigKey("elasticsearch.node.name",
- "Node name (or randomly selected if not set", null);
-
- @SetFromFlag("clusterName")
- StringAttributeSensorAndConfigKey CLUSTER_NAME = new StringAttributeSensorAndConfigKey("elasticsearch.node.cluster.name",
- "Cluster name (or elasticsearch selected if not set", null);
-
- AttributeSensor<String> NODE_ID = Sensors.newStringSensor("elasticsearch.node.id");
- AttributeSensor<Integer> DOCUMENT_COUNT = Sensors.newIntegerSensor("elasticsearch.node.docs.count");
- AttributeSensor<Integer> STORE_BYTES = Sensors.newIntegerSensor("elasticsearch.node.store.bytes");
- AttributeSensor<Integer> GET_TOTAL = Sensors.newIntegerSensor("elasticsearch.node.get.total");
- AttributeSensor<Integer> GET_TIME_IN_MILLIS = Sensors.newIntegerSensor("elasticsearch.node.get.time.in.millis");
- AttributeSensor<Integer> SEARCH_QUERY_TOTAL = Sensors.newIntegerSensor("elasticsearch.node.search.query.total");
- AttributeSensor<Integer> SEARCH_QUERY_TIME_IN_MILLIS = Sensors.newIntegerSensor("elasticsearch.node.search.query.time.in.millis");
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeDriver.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeDriver.java
deleted file mode 100644
index 82640cd..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeDriver.java
+++ /dev/null
@@ -1,25 +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.entity.nosql.elasticsearch;
-
-import org.apache.brooklyn.entity.software.base.SoftwareProcessDriver;
-
-public interface ElasticSearchNodeDriver extends SoftwareProcessDriver {
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeImpl.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeImpl.java
deleted file mode 100644
index c707ee6..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeImpl.java
+++ /dev/null
@@ -1,111 +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.entity.nosql.elasticsearch;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.location.access.BrooklynAccessUtils;
-import org.apache.brooklyn.entity.software.base.SoftwareProcessImpl;
-import org.apache.brooklyn.feed.http.HttpFeed;
-import org.apache.brooklyn.feed.http.HttpPollConfig;
-import org.apache.brooklyn.feed.http.HttpValueFunctions;
-import org.apache.brooklyn.feed.http.JsonFunctions;
-import org.apache.brooklyn.util.http.HttpToolResponse;
-import org.apache.brooklyn.util.guava.Functionals;
-import org.apache.brooklyn.util.guava.Maybe;
-import org.apache.brooklyn.util.guava.MaybeFunctions;
-import org.apache.brooklyn.util.guava.TypeTokens;
-
-import com.google.common.base.Function;
-import com.google.common.base.Functions;
-import com.google.common.net.HostAndPort;
-import com.google.gson.JsonElement;
-
-public class ElasticSearchNodeImpl extends SoftwareProcessImpl implements ElasticSearchNode {
-
- protected static final Function<Maybe<JsonElement>, Maybe<JsonElement>> GET_FIRST_NODE_FROM_NODES = new Function<Maybe<JsonElement>, Maybe<JsonElement>>() {
- @Override public Maybe<JsonElement> apply(Maybe<JsonElement> input) {
- if (input.isAbsent()) {
- return input;
- }
- return Maybe.fromNullable(input.get().getAsJsonObject().entrySet().iterator().next().getValue());
- }
- };
-
- protected static final Function<HttpToolResponse, Maybe<JsonElement>> GET_FIRST_NODE = Functionals.chain(HttpValueFunctions.jsonContents(),
- MaybeFunctions.<JsonElement>wrap(), JsonFunctions.walkM("nodes"), GET_FIRST_NODE_FROM_NODES);
-
-
- HttpFeed httpFeed;
-
- @Override
- public Class<ElasticSearchNodeDriver> getDriverInterface() {
- return ElasticSearchNodeDriver.class;
- }
-
- protected static final <T> HttpPollConfig<T> getSensorFromNodeStat(AttributeSensor<T> sensor, String... jsonPath) {
- return new HttpPollConfig<T>(sensor)
- .onSuccess(Functionals.chain(GET_FIRST_NODE, JsonFunctions.walkM(jsonPath), JsonFunctions.castM(TypeTokens.getRawRawType(sensor.getTypeToken()), null)))
- .onFailureOrException(Functions.<T>constant(null));
- }
-
- @Override
- protected void connectSensors() {
- super.connectSensors();
- Integer rawPort = getAttribute(HTTP_PORT);
- checkNotNull(rawPort, "HTTP_PORT sensors not set for %s; is an acceptable port available?", this);
- HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, rawPort);
- Function<Maybe<JsonElement>, String> getNodeId = new Function<Maybe<JsonElement>, String>() {
- @Override public String apply(Maybe<JsonElement> input) {
- if (input.isAbsent()) {
- return null;
- }
- return input.get().getAsJsonObject().entrySet().iterator().next().getKey();
- }
- };
- httpFeed = HttpFeed.builder()
- .entity(this)
- .period(1000)
- .baseUri(String.format("http://%s:%s/_nodes/_local/stats", hp.getHostText(), hp.getPort()))
- .poll(new HttpPollConfig<Boolean>(SERVICE_UP)
- .onSuccess(HttpValueFunctions.responseCodeEquals(200))
- .onFailureOrException(Functions.constant(false)))
- .poll(new HttpPollConfig<String>(NODE_ID)
- .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(), MaybeFunctions.<JsonElement>wrap(), JsonFunctions.walkM("nodes"), getNodeId))
- .onFailureOrException(Functions.constant("")))
- .poll(getSensorFromNodeStat(NODE_NAME, "name"))
- .poll(getSensorFromNodeStat(DOCUMENT_COUNT, "indices", "docs", "count"))
- .poll(getSensorFromNodeStat(STORE_BYTES, "indices", "store", "size_in_bytes"))
- .poll(getSensorFromNodeStat(GET_TOTAL, "indices", "get", "total"))
- .poll(getSensorFromNodeStat(GET_TIME_IN_MILLIS, "indices", "get", "time_in_millis"))
- .poll(getSensorFromNodeStat(SEARCH_QUERY_TOTAL, "indices", "search", "query_total"))
- .poll(getSensorFromNodeStat(SEARCH_QUERY_TIME_IN_MILLIS, "indices", "search", "query_time_in_millis"))
- .poll(new HttpPollConfig<String>(CLUSTER_NAME)
- .onSuccess(HttpValueFunctions.jsonContents("cluster_name", String.class)))
- .build();
- }
-
- @Override
- protected void disconnectSensors() {
- if (httpFeed != null) {
- httpFeed.stop();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeSshDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeSshDriver.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeSshDriver.java
deleted file mode 100644
index 6e35e8b..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/elasticsearch/ElasticSearchNodeSshDriver.java
+++ /dev/null
@@ -1,139 +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.entity.nosql.elasticsearch;
-
-import static java.lang.String.format;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.List;
-
-import org.apache.brooklyn.api.entity.EntityLocal;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.net.Urls;
-import org.apache.brooklyn.util.os.Os;
-import org.apache.brooklyn.util.ssh.BashCommands;
-
-import com.google.common.collect.ImmutableList;
-
-public class ElasticSearchNodeSshDriver extends AbstractSoftwareProcessSshDriver implements ElasticSearchNodeDriver {
-
- public ElasticSearchNodeSshDriver(EntityLocal entity, SshMachineLocation machine) {
- super(entity, machine);
- }
-
- @Override
- public void preInstall() {
- resolver = Entities.newDownloader(this);
- setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("elasticsearch-%s", getVersion()))));
- }
-
- @Override
- public void install() {
- List<String> urls = resolver.getTargets();
- String saveAs = resolver.getFilename();
-
- List<String> commands = ImmutableList.<String>builder()
- .add(BashCommands.installJavaLatestOrWarn())
- .addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs))
- .add(String.format("tar zxvf %s", saveAs))
- .build();
-
- newScript(INSTALLING).body.append(commands).execute();
- }
-
- @Override
- public void customize() {
- newScript(CUSTOMIZING).execute(); //create the directory
-
- String configFileUrl = entity.getConfig(ElasticSearchNode.TEMPLATE_CONFIGURATION_URL);
-
- if (configFileUrl == null) {
- return;
- }
-
- String configScriptContents = processTemplate(configFileUrl);
- Reader configContents = new StringReader(configScriptContents);
-
- getMachine().copyTo(configContents, Urls.mergePaths(getRunDir(), getConfigFile()));
- }
-
- @Override
- public void launch() {
- String pidFile = getRunDir() + "/" + AbstractSoftwareProcessSshDriver.PID_FILENAME;
- entity.sensors().set(ElasticSearchNode.PID_FILE, pidFile);
- StringBuilder commandBuilder = new StringBuilder()
- .append(String.format("%s/bin/elasticsearch -d -p %s", getExpandedInstallDir(), pidFile));
- if (entity.getConfig(ElasticSearchNode.TEMPLATE_CONFIGURATION_URL) != null) {
- commandBuilder.append(" -Des.config=" + Os.mergePaths(getRunDir(), getConfigFile()));
- }
- appendConfigIfPresent(commandBuilder, "es.path.data", ElasticSearchNode.DATA_DIR, Os.mergePaths(getRunDir(), "data"));
- appendConfigIfPresent(commandBuilder, "es.path.logs", ElasticSearchNode.LOG_DIR, Os.mergePaths(getRunDir(), "logs"));
- appendConfigIfPresent(commandBuilder, "es.node.name", ElasticSearchNode.NODE_NAME.getConfigKey());
- appendConfigIfPresent(commandBuilder, "es.cluster.name", ElasticSearchNode.CLUSTER_NAME.getConfigKey());
- appendConfigIfPresent(commandBuilder, "es.discovery.zen.ping.multicast.enabled", ElasticSearchNode.MULTICAST_ENABLED);
- appendConfigIfPresent(commandBuilder, "es.discovery.zen.ping.unicast.enabled", ElasticSearchNode.UNICAST_ENABLED);
- commandBuilder.append(" > out.log 2> err.log < /dev/null");
- newScript(MutableMap.of("usePidFile", false), LAUNCHING)
- .updateTaskAndFailOnNonZeroResultCode()
- .body.append(commandBuilder.toString())
- .execute();
- }
-
- private void appendConfigIfPresent(StringBuilder builder, String parameter, ConfigKey<?> configKey) {
- appendConfigIfPresent(builder, parameter, configKey, null);
- }
-
- private void appendConfigIfPresent(StringBuilder builder, String parameter, ConfigKey<?> configKey, String defaultValue) {
- String config = null;
- if (entity.getConfig(configKey) != null) {
- config = String.valueOf(entity.getConfig(configKey));
- }
- if (config == null && defaultValue != null) {
- config = defaultValue;
- }
- if (config != null) {
- builder.append(String.format(" -D%s=%s", parameter, config));
- }
- }
-
- public String getConfigFile() {
- return "elasticsearch.yaml";
- }
-
- @Override
- public boolean isRunning() {
- return newScript(MutableMap.of("usePidFile", true), CHECK_RUNNING).execute() == 0;
- }
-
- @Override
- public void stop() {
- newScript(MutableMap.of("usePidFile", true), STOPPING).execute();
- }
-
- @Override
- public void kill() {
- newScript(MutableMap.of("usePidFile", true), KILLING).execute();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastCluster.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastCluster.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastCluster.java
deleted file mode 100644
index 3962fd1..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastCluster.java
+++ /dev/null
@@ -1,59 +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.entity.nosql.hazelcast;
-
-import java.util.List;
-
-import com.google.common.reflect.TypeToken;
-
-import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.entity.group.DynamicCluster;
-
-/**
- * A cluster of {@link HazelcastNode}s based on {@link DynamicCluster}.
- */
-@Catalog(name="Hazelcast Cluster", description="Hazelcast is a clustering and highly scalable data distribution platform for Java.")
-
-@ImplementedBy(HazelcastClusterImpl.class)
-public interface HazelcastCluster extends DynamicCluster {
-
- @SetFromFlag("clusterName")
- BasicAttributeSensorAndConfigKey<String> CLUSTER_NAME = new BasicAttributeSensorAndConfigKey<String>(String.class,
- "hazelcast.cluster.name", "Name of the Hazelcast cluster", "HazelcastCluster");
-
- @SetFromFlag("clusterPassword")
- ConfigKey<String> CLUSTER_PASSWORD =
- ConfigKeys.newStringConfigKey("hazelcast.cluster.password", "Hazelcast cluster password.");
-
- @SuppressWarnings("serial")
- AttributeSensor<List<String>> PUBLIC_CLUSTER_NODES = Sensors.newSensor(new TypeToken<List<String>>() {},
- "hazelcast.cluster.public.nodes", "List of public addresses of all nodes in the cluster");
-
- String getClusterName();
-
- String getClusterPassword();
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastClusterImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastClusterImpl.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastClusterImpl.java
deleted file mode 100644
index 854c0a3..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastClusterImpl.java
+++ /dev/null
@@ -1,125 +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.entity.nosql.hazelcast;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Lists;
-import org.apache.brooklyn.api.entity.Entity;
-
-import org.apache.brooklyn.entity.group.AbstractMembershipTrackingPolicy;
-import org.apache.brooklyn.entity.group.DynamicClusterImpl;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.policy.PolicySpec;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.util.text.Strings;
-
-public class HazelcastClusterImpl extends DynamicClusterImpl implements HazelcastCluster {
- private static final Logger LOG = LoggerFactory.getLogger(HazelcastClusterImpl.class);
-
- private static final AtomicInteger nextMemberId = new AtomicInteger(0);
-
- @Override
- protected EntitySpec<?> getMemberSpec() {
- EntitySpec<?> spec = EntitySpec.create(config().get(HazelcastCluster.MEMBER_SPEC));
-
- spec.configure(HazelcastNode.NODE_CLUSTER_NAME, config().get(HazelcastCluster.CLUSTER_NAME));
- spec.configure(HazelcastNode.GROUP_NAME, config().get(HazelcastCluster.CLUSTER_NAME));
-
- if (LOG.isInfoEnabled()) {
- LOG.info("Cluster name : {} : used as a group name", getConfig(HazelcastNode.GROUP_NAME));
- }
-
- spec.configure(HazelcastNode.GROUP_PASSWORD, getClusterPassword());
-
- return spec;
- }
-
- @Override
- public void init() {
- super.init();
-
- String clusterPassword = getClusterPassword();
-
- if (Strings.isBlank(clusterPassword)) {
- if (LOG.isInfoEnabled()) {
- LOG.info(this + " cluster password not provided for " + CLUSTER_PASSWORD.getName() + " : generating random password");
- }
- config().set(CLUSTER_PASSWORD, Strings.makeRandomId(12));
- }
-
- policies().add(PolicySpec.create(MemberTrackingPolicy.class)
- .displayName("Hazelcast members tracker")
- .configure("group", this));
- }
-
- public static class MemberTrackingPolicy extends AbstractMembershipTrackingPolicy {
- @Override
- protected void onEntityChange(Entity member) {
- }
-
- @Override
- protected void onEntityAdded(Entity member) {
- if (member.getAttribute(HazelcastNode.NODE_NAME) == null) {
- ((EntityInternal) member).sensors().set(HazelcastNode.NODE_NAME, "hazelcast-" + nextMemberId.incrementAndGet());
- if (LOG.isInfoEnabled()) {
- LOG.info("Node {} added to the cluster", member);
- }
- }
- }
-
- @Override
- protected void onEntityRemoved(Entity member) {
- }
- };
-
- @Override
- public String getClusterName() {
- return getConfig(CLUSTER_NAME);
- }
-
- @Override
- public String getClusterPassword() {
- return getConfig(CLUSTER_PASSWORD);
- }
-
- @Override
- protected void initEnrichers() {
- super.initEnrichers();
-
- }
-
- @Override
- public void start(Collection<? extends Location> locations) {
- super.start(locations);
-
- List<String> clusterNodes = Lists.newArrayList();
- for (Entity member : getMembers()) {
- clusterNodes.add(member.getAttribute(Attributes.ADDRESS));
- }
- sensors().set(PUBLIC_CLUSTER_NODES, clusterNodes);
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNode.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNode.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNode.java
deleted file mode 100644
index 768179c..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNode.java
+++ /dev/null
@@ -1,101 +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.entity.nosql.hazelcast;
-
-import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.location.PortRanges;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey.StringAttributeSensorAndConfigKey;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.entity.java.UsesJava;
-import org.apache.brooklyn.entity.java.UsesJmx;
-import org.apache.brooklyn.util.javalang.JavaClassNames;
-
-/**
- * An {@link brooklyn.entity.Entity} that represents an Hazelcast node
- */
-@Catalog(name="Hazelcast Node", description="Hazelcast is a clustering and highly scalable data distribution platform for Java.")
-
-@ImplementedBy(HazelcastNodeImpl.class)
-public interface HazelcastNode extends SoftwareProcess, UsesJava, UsesJmx {
- @SetFromFlag("version")
- ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "3.5.4");
-
- @SetFromFlag("downloadUrl")
- BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new BasicAttributeSensorAndConfigKey<String>(
- SoftwareProcess.DOWNLOAD_URL, "https://repo1.maven.org/maven2/com/hazelcast/hazelcast/${version}/hazelcast-${version}.jar");
-
- @SetFromFlag("configTemplateUrl")
- ConfigKey<String> CONFIG_TEMPLATE_URL = ConfigKeys.newStringConfigKey(
- "hazelcast.node.config.templateUrl", "Template file (in freemarker format) for the Hazelcat config file",
- JavaClassNames.resolveClasspathUrl(HazelcastNode.class, "hazelcast-brooklyn.xml"));
-
- @SetFromFlag("configFileName")
- ConfigKey<String> CONFIG_FILE_NAME = ConfigKeys.newStringConfigKey(
- "hazelcast.node.config.fileName", "Name of the Hazelcast config file", "hazelcast.xml");
-
- @SetFromFlag("nodeName")
- StringAttributeSensorAndConfigKey NODE_NAME = new StringAttributeSensorAndConfigKey("hazelcast.node.name",
- "Node name (or randomly selected if not set", null);
-
- @SetFromFlag("nodeHeapMemorySize")
- ConfigKey<String> NODE_HEAP_MEMORY_SIZE = ConfigKeys.newStringConfigKey(
- "hazelcast.node.heap.memory.size", "Node's heap memory size (-Xmx and -Xms) in megabytes. Default: 256m", "256m");
-
- @SetFromFlag("nodePort")
- PortAttributeSensorAndConfigKey NODE_PORT = new PortAttributeSensorAndConfigKey("hazelcast.node.port", "Hazelcast communication port", PortRanges.fromString("5701+"));
-
- @SetFromFlag("nodeClusterName")
- BasicAttributeSensorAndConfigKey<String> NODE_CLUSTER_NAME = new BasicAttributeSensorAndConfigKey<String>(String.class,
- "hazelcast.node.cluster.name", "Name of the Hazelcast cluster which node is part of", "");
-
- /**
- * Specifies the group name in the configuration file. Each Hazelcast cluster has a separate group.
- */
- @SetFromFlag("groupName")
- ConfigKey<String> GROUP_NAME = ConfigKeys.newStringConfigKey("hazelcast.group.name",
- "Group name", "brooklyn");
-
- @SetFromFlag("groupPassword")
- ConfigKey<String> GROUP_PASSWORD = ConfigKeys.newStringConfigKey("hazelcast.group.password",
- "Group password", "brooklyn");
-
- String getNodeName();
-
- Integer getNodePort();
-
- String getGroupName();
-
- String getGroupPassword();
-
- String getHostname();
-
- String getHostAddress();
-
- String getPrivateIpAddress();
-
- String getListenAddress();
-
- String getHeapMemorySize();
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNodeDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNodeDriver.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNodeDriver.java
deleted file mode 100644
index 8cf1e0c..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNodeDriver.java
+++ /dev/null
@@ -1,25 +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.entity.nosql.hazelcast;
-
-import org.apache.brooklyn.entity.software.base.SoftwareProcessDriver;
-
-public interface HazelcastNodeDriver extends SoftwareProcessDriver {
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNodeImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNodeImpl.java b/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNodeImpl.java
deleted file mode 100644
index 6d13b74..0000000
--- a/brooklyn-library/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/hazelcast/HazelcastNodeImpl.java
+++ /dev/null
@@ -1,146 +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.entity.nosql.hazelcast;
-
-import java.net.URI;
-import java.util.concurrent.TimeUnit;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.location.access.BrooklynAccessUtils;
-import org.apache.brooklyn.entity.software.base.SoftwareProcessImpl;
-import org.apache.brooklyn.feed.http.HttpFeed;
-import org.apache.brooklyn.feed.http.HttpPollConfig;
-import org.apache.brooklyn.feed.http.HttpValueFunctions;
-import org.apache.brooklyn.util.text.Strings;
-
-import com.google.common.base.Functions;
-import com.google.common.net.HostAndPort;
-
-public class HazelcastNodeImpl extends SoftwareProcessImpl implements HazelcastNode {
-
- private static final Logger LOG = LoggerFactory.getLogger(HazelcastNodeImpl.class);
-
- HttpFeed httpFeed;
-
- @Override
- public Class<HazelcastNodeDriver> getDriverInterface() {
- return HazelcastNodeDriver.class;
- }
-
- @Override
- protected void connectSensors() {
- super.connectSensors();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Connecting sensors for node: {} ", getAttribute(Attributes.HOSTNAME));
- }
-
- HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getNodePort());
-
- String nodeUri = String.format("http://%s:%d/hazelcast/rest/cluster", hp.getHostText(), hp.getPort());
- sensors().set(Attributes.MAIN_URI, URI.create(nodeUri));
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Node {} is using {} as a main URI", this, nodeUri);
- }
-
- httpFeed = HttpFeed.builder()
- .entity(this)
- .period(3000, TimeUnit.MILLISECONDS)
- .baseUri(nodeUri)
- .poll(new HttpPollConfig<Boolean>(SERVICE_UP)
- .onSuccess(HttpValueFunctions.responseCodeEquals(200))
- .onFailureOrException(Functions.constant(false)))
- .build();
- }
-
- @Override
- protected void disconnectSensors() {
- if (httpFeed != null) {
- httpFeed.stop();
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Disconnecting sensors for node: {} ", getAttribute(Attributes.HOSTNAME));
- }
-
- super.disconnectSensors();
- disconnectServiceUpIsRunning();
- }
-
-
- @Override
- public String getGroupName() {
- return getConfig(HazelcastNode.GROUP_NAME);
- }
-
- @Override
- public String getGroupPassword() {
- return getConfig(HazelcastNode.GROUP_PASSWORD);
- }
-
- @Override
- public String getNodeName() {
- return getAttribute(HazelcastNode.NODE_NAME);
- }
-
- @Override
- public Integer getNodePort() {
- return getAttribute(HazelcastNode.NODE_PORT);
- }
-
- @Override
- public String getHostname() {
- return getAttribute(HOSTNAME);
- }
-
- @Override
- public String getHostAddress() {
- return getAttribute(ADDRESS);
- }
-
- @Override
- public String getPrivateIpAddress() {
- return getAttribute(SUBNET_ADDRESS);
- }
-
- @Override
- public String getListenAddress() {
- String listenAddress = getPrivateIpAddress();
-
- if (Strings.isBlank(listenAddress)) {
- listenAddress = getAttribute(ADDRESS);
- }
-
- if (LOG.isInfoEnabled()) {
- LOG.info("Node {} is listening on {}", this, listenAddress);
- }
-
- return listenAddress;
- }
-
-
- @Override
- public String getHeapMemorySize() {
- return getConfig(HazelcastNode.NODE_HEAP_MEMORY_SIZE);
- }
-
-}