Add Solr support
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/3a809979 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/3a809979 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/3a809979 Branch: refs/heads/master Commit: 3a80997965e8f3eb10714a082e059731312b5d14 Parents: 076bf52 Author: Valentin Aitken <[email protected]> Authored: Tue May 12 02:17:02 2015 +0300 Committer: Valentin Aitken <[email protected]> Committed: Tue Jul 14 11:27:07 2015 +0100 ---------------------------------------------------------------------- .../brooklyn/entity/nosql/riak/RiakNode.java | 18 ++++++++-- .../entity/nosql/riak/RiakNodeImpl.java | 21 ++++++++++-- .../entity/nosql/riak/RiakNodeSshDriver.java | 17 ++++++++-- .../nosql/riak/riak-cluster-with-solr.yaml | 35 ++++++++++++++++++++ .../brooklyn/entity/nosql/riak/riak.conf | 2 +- 5 files changed, 85 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3a809979/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java index 1f29366..ae897ad 100644 --- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java +++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNode.java @@ -29,6 +29,7 @@ import brooklyn.entity.basic.Attributes; import brooklyn.entity.basic.ConfigKeys; import brooklyn.entity.basic.MethodEffector; import brooklyn.entity.basic.SoftwareProcess; +import brooklyn.entity.java.UsesJava; import brooklyn.entity.proxying.ImplementedBy; import brooklyn.event.AttributeSensor; import brooklyn.event.basic.AttributeSensorAndConfigKey; @@ -42,7 +43,7 @@ import com.google.common.reflect.TypeToken; @Catalog(name="Riak Node", description="Riak is a distributed NoSQL key-value data store that offers " + "extremely high availability, fault tolerance, operational simplicity and scalability.") @ImplementedBy(RiakNodeImpl.class) -public interface RiakNode extends SoftwareProcess { +public interface RiakNode extends SoftwareProcess, UsesJava { @SetFromFlag("version") ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, @@ -123,8 +124,17 @@ public interface RiakNode extends SoftwareProcess { PortAttributeSensorAndConfigKey EPMD_LISTENER_PORT = new PortAttributeSensorAndConfigKey("epmdListenerPort", "Erlang Port Mapper Daemon Listener Port", "4369"); PortAttributeSensorAndConfigKey ERLANG_PORT_RANGE_START = new PortAttributeSensorAndConfigKey("erlangPortRangeStart", "Erlang Port Range Start", "6000+"); PortAttributeSensorAndConfigKey ERLANG_PORT_RANGE_END = new PortAttributeSensorAndConfigKey("erlangPortRangeEnd", "Erlang Port Range End", "7999+"); - PortAttributeSensorAndConfigKey SEARCH_SOLR_PORT = new PortAttributeSensorAndConfigKey("search.solr.port", "Solr port", "8093+"); - PortAttributeSensorAndConfigKey SEARCH_SOLR_JMX_PORT = new PortAttributeSensorAndConfigKey("search.solr.jmx_port", "Solr port", "8985+"); + + @SetFromFlag("searchEnabled") + ConfigKey<Boolean> SEARCH_ENABLED = ConfigKeys.newBooleanConfigKey("riak.search", "Deploy Solr and configure Riak to use it", false); + + /** + * http://docs.basho.com/riak/latest/dev/using/search/ + * Solr is powered by Riak's Yokozuna engine and it is used through the riak webport + * So SEARCH_SOLR_PORT shouldn't be exposed + */ + ConfigKey<Integer> SEARCH_SOLR_PORT = ConfigKeys.newIntegerConfigKey("search.solr.port", "Solr port", 8983); + ConfigKey<Integer> SEARCH_SOLR_JMX_PORT = ConfigKeys.newIntegerConfigKey("search.solr.jmx_port", "Solr port", 8985); AttributeSensor<Integer> NODE_GETS = Sensors.newIntegerSensor("riak.node.gets", "Gets in the last minute"); AttributeSensor<Integer> NODE_GETS_TOTAL = Sensors.newIntegerSensor("riak.node.gets.total", "Total gets since node started"); @@ -182,6 +192,8 @@ public interface RiakNode extends SoftwareProcess { Integer getErlangPortRangeEnd(); + Boolean isSearchEnabled(); + Integer getSearchSolrPort(); Integer getSearchSolrJmxPort(); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3a809979/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java index 590cb3a..7dda317 100644 --- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java +++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java @@ -189,6 +189,7 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode { WebAppServiceMethods.connectWebAppServerPolicies(this); } + @Override public void disconnectSensors() { super.disconnectSensors(); if (httpFeed != null) { @@ -242,46 +243,62 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode { getDriver().recoverFailedNode(nodeName); } + @Override public Integer getRiakWebPort() { return getAttribute(RiakNode.RIAK_WEB_PORT); } + @Override public Integer getRiakPbPort() { return getAttribute(RiakNode.RIAK_PB_PORT); } + @Override public Integer getHandoffListenerPort() { return getAttribute(RiakNode.HANDOFF_LISTENER_PORT); } + @Override public Integer getEpmdListenerPort() { return getAttribute(RiakNode.EPMD_LISTENER_PORT); } + @Override public Integer getErlangPortRangeStart() { return getAttribute(RiakNode.ERLANG_PORT_RANGE_START); } + @Override public Integer getErlangPortRangeEnd() { return getAttribute(RiakNode.ERLANG_PORT_RANGE_END); } + @Override + public Boolean isSearchEnabled() { + return getConfig(RiakNode.SEARCH_ENABLED); + } + + @Override public Integer getSearchSolrPort() { - return getAttribute(RiakNode.SEARCH_SOLR_PORT); + return getConfig(RiakNode.SEARCH_SOLR_PORT); } + @Override public Integer getSearchSolrJmxPort() { - return getAttribute(RiakNode.SEARCH_SOLR_JMX_PORT); + return getConfig(RiakNode.SEARCH_SOLR_JMX_PORT); } + @Override public String getMajorVersion() { return getFullVersion().substring(0, 3); } + @Override public String getFullVersion() { return getConfig(RiakNode.SUGGESTED_VERSION); } + @Override public String getOsMajorVersion() { return getDriver().getOsMajorVersion(); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3a809979/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java index 856c029..7ad15d7 100644 --- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java +++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java @@ -36,10 +36,10 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import brooklyn.entity.java.JavaSoftwareProcessSshDriver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver; import brooklyn.entity.basic.Attributes; import brooklyn.entity.basic.Entities; import brooklyn.entity.basic.lifecycle.ScriptHelper; @@ -61,7 +61,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; // TODO: Alter -env ERL_CRASH_DUMP path in vm.args -public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implements RiakNodeDriver { +public class RiakNodeSshDriver extends JavaSoftwareProcessSshDriver implements RiakNodeDriver { private static final Logger LOG = LoggerFactory.getLogger(RiakNodeSshDriver.class); private static final String sbinPath = "$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"; @@ -72,6 +72,11 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implemen } @Override + protected String getLogFileLocation() { + return "/var/log/riak/solr.log"; + } + + @Override public RiakNodeImpl getEntity() { return RiakNodeImpl.class.cast(super.getEntity()); } @@ -558,6 +563,14 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver implemen } } + @Override + public void setup() { + if(entity.getConfig(RiakNode.SEARCH_ENABLED)) { + // JavaSoftwareProcessSshDriver.setup() is called in order to install java + super.setup(); + } + } + private Boolean hasJoinedCluster() { return Boolean.TRUE.equals(entity.getAttribute(RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER)); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3a809979/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak-cluster-with-solr.yaml ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak-cluster-with-solr.yaml b/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak-cluster-with-solr.yaml new file mode 100644 index 0000000..93ef146 --- /dev/null +++ b/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak-cluster-with-solr.yaml @@ -0,0 +1,35 @@ +# +# 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. +# + +name: Cluster Riak & Solr +location: + jclouds:aws-ec2:us-east-1: + osFamily: centos + osVersionRegex: 6\..* +services: +- type: brooklyn.entity.nosql.riak.RiakCluster + initialSize: 2 + memberSpec: + $brooklyn:entitySpec: + type: brooklyn.entity.nosql.riak.RiakNode + searchEnabled: true + brooklyn.config: + provisioning.properties: + minCores: 2 + minRam: 6gb \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3a809979/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak.conf ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak.conf b/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak.conf index 1c96fc0..125fa77 100644 --- a/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak.conf +++ b/software/nosql/src/main/resources/brooklyn/entity/nosql/riak/riak.conf @@ -447,7 +447,7 @@ leveldb.maximum_memory.percent = 70 ## ## Acceptable values: ## - on or off -search = off +search = ${entity.isSearchEnabled()?string('on','off')} ## How long Riak will wait for Solr to start. The start sequence ## will be tried twice. If both attempts timeout, then the Riak node
