Git Product home page Git Product logo

dropwizard-elasticsearch's Introduction

Dropwizard

Build Quality Gate Status Maven Central Javadocs Documentation Status Maintainability Reproducible Builds Contribute with Gitpod

Dropwizard is a sneaky way of making fast Java web applications.

It's a little bit of opinionated glue code which bangs together a set of libraries which have historically not sucked:

Read more at dropwizard.io.

Want to contribute to Dropwizard?

Before working on the code, if you plan to contribute changes, please read the following CONTRIBUTING document.

Need help or found an issue?

When reporting an issue through the issue tracker on GitHub or sending an email to the Dropwizard User Google Group mailing list, please use the following guidelines:

  • Check existing issues to see if it has been addressed already
  • The version of Dropwizard you are using
  • A short description of the issue you are experiencing and the expected outcome
  • Description of how someone else can reproduce the problem
  • Paste error output or logs in your issue or in a Gist. If pasting them in the GitHub issue, wrap it in three backticks: ``` so that it renders nicely
  • Write a unit test to show the issue!

Sponsors

Dropwizard is generously supported by some companies with licenses and free accounts for their products.

JetBrains

JetBrains

JetBrains supports our open source project by sponsoring some All Products Packs within their Free Open Source License program.

dropwizard-elasticsearch's People

Contributors

akshay0709 avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar joschi avatar jplock avatar mattiasholmqvist avatar ricola77 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropwizard-elasticsearch's Issues

Any documentation/tutorial available?

Hi,
Is there a tutorial for dropwizard-elasticsearch usage? I can't find anything in documentation regarding setup and real usage.
For example, how to use the EsConfiguration class, how to name the .yml file for es conf, and how to run and use the ElasticSearch API throughout the Dropwizard application.

Moreover, when I try to register the ManagedEsClient, I got into the error "cannot find symbol : method lifecycle()":

env.lifecycle().manage(managedClient);

Should I configure or enable something in my drop wizard application?

Thanks,

Got a warning java.net.UnknownHostException

Is there a resolution for the below exception without modifying the /etc/hosts file?

java -Ddw.database.password=Qn8TZxFFD77tzQwc -jar supply-server-0.0.1-SNAPSHOT.jar server review-service.yaml
INFO  [2015-05-29 23:24:59,401] com.appirio.service.supply.v2auth.JWTAuthProvider: Loading the secret data..
INFO  [2015-05-29 23:24:59,403] com.appirio.service.supply.v2auth.JWTAuthProvider: Loaded the secret data successfully.
INFO  [2015-05-29 23:24:59,582] org.elasticsearch.plugins: [elasticsearch01] loaded [], sites []
WARN  [2015-05-29 23:25:00,384] org.elasticsearch.common.network: failed to resolve local host, fallback to loopback
! java.net.UnknownHostException: ip-10-15-80-156: unknown error
! at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_40]
! at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907) ~[na:1.8.0_40]
! at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302) ~[na:1.8.0_40]
! at java.net.InetAddress.getLocalHost(InetAddress.java:1479) ~[na:1.8.0_40]
! ... 16 common frames omitted
! Causing: java.net.UnknownHostException: ip-10-15-80-156: ip-10-15-80-156: unknown error
! at java.net.InetAddress.getLocalHost(InetAddress.java:1484) ~[na:1.8.0_40]
! at org.elasticsearch.common.network.NetworkUtils.<clinit>(NetworkUtils.java:55) ~[supply-server-0.0.1-SNAPSHOT.jar:na]
! at org.elasticsearch.transport.netty.NettyTransport.createClientBootstrap(NettyTransport.java:350) [supply-server-0.0.1-SNAPSHOT.jar:na]
! at org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:250) [supply-server-0.0.1-SNAPSHOT.jar:na]
! at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:85) [supply-server-0.0.1-SNAPSHOT.jar:na]
! at org.elasticsearch.transport.TransportService.doStart(TransportService.java:91) [supply-server-0.0.1-SNAPSHOT.jar:na]
! at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:85) [supply-server-0.0.1-SNAPSHOT.jar:na]
! at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:189) [supply-server-0.0.1-SNAPSHOT.jar:na]
! at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:123) [supply-server-0.0.1-SNAPSHOT.jar:na]
! at io.dropwizard.elasticsearch.managed.ManagedEsClient.<init>(ManagedEsClient.java:51) [supply-server-0.0.1-SNAPSHOT.jar:na]
! at com.appirio.service.supply.SupplyServerApplication.run(SupplyServerApplication.java:95) [supply-server-0.0.1-SNAPSHOT.jar:na]

MasterNotDiscoveredException

Hi,

I'm getting MasterNotDiscoveredException with these configurations:

clusterName: dropwizard_elasticsearch_test
settings:
  cluster.name: dropwizard_elasticsearch_test
  path.home: "target/data"
  network.host: 127.0.0.1
  transport.tcp.port: 29300-29400

Do you have any idea why I'm getting this error? Is this related with multicast/unicast configuration?

Thanks in advance!

full log :

INFO  [2016-03-03 17:30:55,002] rest.suppressed: /_cluster/health Params: {pretty=true}
! org.elasticsearch.discovery.MasterNotDiscoveredException: waited for [30s]
! at org.elasticsearch.action.support.master.TransportMasterNodeAction$4.onTimeout(TransportMasterNodeAction.java:154) ~[elasticsearch-2.1.1.jar:2.1.1]
! at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:239) ~[elasticsearch-2.1.1.jar:2.1.1]
! at org.elasticsearch.cluster.service.InternalClusterService$NotifyTimeout.run(InternalClusterService.java:574) ~[elasticsearch-2.1.1.jar:2.1.1]
! at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_79]
! at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_79]
! at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]

Break of compatibility in EsClusterHealthCheck version 2.3 or above

In the version 2.3 in ES the class ClusterHealthStatus was changed to the package org.elasticsearch.cluster.health.ClusterHealthStatus. So using the EsClusterHealthCheck will break compatibility.
In my project I did a copy just fixing the package:

import static com.google.common.base.Preconditions.checkNotNull;

import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.health.ClusterHealthStatus;

import com.codahale.metrics.health.HealthCheck;

/**
 * A {@link HealthCheck} which checks the cluster state of an Elasticsearch cluster.
 *
 * @see <a href="http://www.elasticsearch.org/guide/reference/api/admin-cluster-health/">Admin Cluster Health</a>
 * To use in elasticsearch version 2.3 or above
 */
public class EsClusterHealthCheck23 extends HealthCheck {
    private final Client client;
    private final boolean failOnYellow;

    /**
     * Construct a new Elasticsearch cluster health check.
     *
     * @param client       an Elasticsearch {@link Client} instance connected to the cluster
     * @param failOnYellow whether the health check should fail if the cluster health state is yellow
     */
    public EsClusterHealthCheck23(Client client, boolean failOnYellow) {
        this.client = checkNotNull(client);
        this.failOnYellow = failOnYellow;
    }

    /**
     * Construct a new Elasticsearch cluster health check which will fail if the cluster health state is
     * {@link ClusterHealthStatus#RED}.
     *
     * @param client an Elasticsearch {@link Client} instance connected to the cluster
     */
    public EsClusterHealthCheck23(Client client) {
        this(client, false);
    }

    /**
     * Perform a check of the Elasticsearch cluster health.
     *
     * @return if the Elasticsearch cluster is healthy, a healthy {@link com.codahale.metrics.health.HealthCheck.Result};
     *         otherwise, an unhealthy {@link com.codahale.metrics.health.HealthCheck.Result} with a descriptive error
     *         message or exception
     * @throws Exception if there is an unhandled error during the health check; this will result in
     *                   a failed health check
     */
    @Override
    protected Result check() throws Exception {
        final ClusterHealthStatus status = client.admin().cluster().prepareHealth().get().getStatus();

        if (status == ClusterHealthStatus.RED || (failOnYellow && status == ClusterHealthStatus.YELLOW)) {
            return Result.unhealthy("Last status: %s", status.name());
        } else {
            return Result.healthy("Last status: %s", status.name());
        }
    }
}

Usage section is stale

I had to update to following :

ManagedEsClient managedClient = new ManagedEsClient(configuration.getEsConfiguration());
environment.lifecycle().manage(managedClient);
environment.healthChecks().register("Cluster health", new EsClusterHealthCheck(managedClient.getClient()));

install elasticsearch plugins

Let's say I want to install Elasticsearch mapper-attachments plugin only for my node, it this possible just by adding the below dependency into the .pom file of my dropwizard application?

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch-mapper-attachments</artifactId>
    <version>3.1.2</version>
</dependency>

How to access client in Resource request

Would be awesome to show exactly how to access a client instance from within a resource.

Is the prescribed method to add a parameter to the init function for the resource with the client or is there some way to do a wrapper like "@context" to grab the client?

Add support for ES Client Plugins

Please add support for adding ES Client Plugins (like the org.elasticsearch.index.reindex.ReindexPlugin). Currently it's not possible to configure one or more plugins via EsConfiguration.

As a workaround I've to do something like:

ManagedEsClient prepareEsClient = new ManagedEsClient(configuration.getEsConfiguration());
TransportAddress[] addresses = TransportAddressHelper.fromHostAndPorts(configuration.getEsConfiguration().getServers());
// Rebuild Client with ReindexPlugin (unsupported in ManagedEsClient) 
ManagedEsClient elasticsearchClient = new ManagedEsClient(TransportClient.builder()
              .settings(prepareEsClient.getClient().settings())
              .addPlugin(ReindexPlugin.class)
              .build()
              .addTransportAddresses(addresses));

Support for ElasticSearch v5 ?

Hi,

I'm getting error java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0] when making request to ElasticSearch v5.

Will there be a release for ElasticSearch v5.x support soon?

Managed elasticsearch node instance?

Hi,

the README says that this client was inspired by the dropwizard-blog-sample.

The original sample also includes a ElasticSearchManager class, which seems to manage a fully-fledged elasticsearch node for embedded usage.

Is there a reason why this is not included in the 'official' dropwizard module?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.