update airline dependency to 2.x (#12270)

* upgrade Airline to Airline 2
  https://github.com/airlift/airline is no longer maintained, updating to
  https://github.com/rvesse/airline (Airline 2) to use an actively
  maintained version, while minimizing breaking changes.

  Note, this is a backwards incompatible change, and extensions relying on
  the CliCommandCreator extension point will also need to be updated.

* fix dependency checks where jakarta.inject is now resolved first instead
  of javax.inject, due to Airline 2 using jakarta
This commit is contained in:
Xavier Léauté 2022-02-27 15:19:28 -08:00 committed by GitHub
parent 4c61878f9c
commit 1434197ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 163 additions and 121 deletions

View File

@ -172,7 +172,7 @@
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.airlift</groupId> <groupId>com.github.rvesse</groupId>
<artifactId>airline</artifactId> <artifactId>airline</artifactId>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -19,7 +19,7 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import io.airlift.airline.Cli; import com.github.rvesse.airline.builder.CliBuilder;
import org.apache.druid.guice.annotations.ExtensionPoint; import org.apache.druid.guice.annotations.ExtensionPoint;
/** /**
@ -32,5 +32,5 @@ import org.apache.druid.guice.annotations.ExtensionPoint;
@ExtensionPoint @ExtensionPoint
public interface CliCommandCreator public interface CliCommandCreator
{ {
void addCommands(Cli.CliBuilder builder); void addCommands(CliBuilder builder);
} }

View File

@ -85,6 +85,10 @@
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
</dependency> </dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.google.inject</groupId> <groupId>com.google.inject</groupId>
<artifactId>guice</artifactId> <artifactId>guice</artifactId>
@ -105,10 +109,6 @@
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId> <artifactId>jsr311-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty</artifactId> <artifactId>netty</artifactId>

View File

@ -62,7 +62,7 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.airlift</groupId> <groupId>com.github.rvesse</groupId>
<artifactId>airline</artifactId> <artifactId>airline</artifactId>
</dependency> </dependency>
<dependency> <dependency>
@ -597,7 +597,7 @@
<KAFKA_VERSION>${apache.kafka.version}</KAFKA_VERSION> <KAFKA_VERSION>${apache.kafka.version}</KAFKA_VERSION>
<ZK_VERSION>${zookeeper.version}</ZK_VERSION> <ZK_VERSION>${zookeeper.version}</ZK_VERSION>
<HADOOP_VERSION>${hadoop.compile.version}</HADOOP_VERSION> <HADOOP_VERSION>${hadoop.compile.version}</HADOOP_VERSION>
<DRUID_VERSION>${parent.version}</DRUID_VERSION> <DRUID_VERSION>${project.parent.version}</DRUID_VERSION>
</environmentVariables> </environmentVariables>
<executable>${project.basedir}/build_run_cluster.sh</executable> <executable>${project.basedir}/build_run_cluster.sh</executable>
</configuration> </configuration>
@ -614,7 +614,7 @@
<DRUID_INTEGRATION_TEST_GROUP>${groups}</DRUID_INTEGRATION_TEST_GROUP> <DRUID_INTEGRATION_TEST_GROUP>${groups}</DRUID_INTEGRATION_TEST_GROUP>
<DRUID_INTEGRATION_TEST_OVERRIDE_CONFIG_PATH>${override.config.path}</DRUID_INTEGRATION_TEST_OVERRIDE_CONFIG_PATH> <DRUID_INTEGRATION_TEST_OVERRIDE_CONFIG_PATH>${override.config.path}</DRUID_INTEGRATION_TEST_OVERRIDE_CONFIG_PATH>
<DRUID_INTEGRATION_TEST_INDEXER>${it.indexer}</DRUID_INTEGRATION_TEST_INDEXER> <DRUID_INTEGRATION_TEST_INDEXER>${it.indexer}</DRUID_INTEGRATION_TEST_INDEXER>
<DRUID_VERSION>${parent.version}</DRUID_VERSION> <DRUID_VERSION>${project.parent.version}</DRUID_VERSION>
</environmentVariables> </environmentVariables>
<executable>${project.basedir}/stop_cluster.sh</executable> <executable>${project.basedir}/stop_cluster.sh</executable>
</configuration> </configuration>

View File

@ -20,6 +20,7 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rvesse.airline.annotations.Command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -28,7 +29,6 @@ import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import com.google.inject.servlet.GuiceFilter; import com.google.inject.servlet.GuiceFilter;
import io.airlift.airline.Command;
import org.apache.druid.client.coordinator.CoordinatorClient; import org.apache.druid.client.coordinator.CoordinatorClient;
import org.apache.druid.discovery.NodeRole; import org.apache.druid.discovery.NodeRole;
import org.apache.druid.guice.Jerseys; import org.apache.druid.guice.Jerseys;

View File

@ -19,9 +19,9 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.google.inject.Binder; import com.google.inject.Binder;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.airlift.airline.Command;
import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LazySingleton;
import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.query.QuerySegmentWalker; import org.apache.druid.query.QuerySegmentWalker;

View File

@ -19,12 +19,12 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import io.airlift.airline.Cli; import com.github.rvesse.airline.builder.CliBuilder;
public class CustomNodeRoleCommandCreator implements CliCommandCreator public class CustomNodeRoleCommandCreator implements CliCommandCreator
{ {
@Override @Override
public void addCommands(Cli.CliBuilder builder) public void addCommands(CliBuilder builder)
{ {
builder.withGroup("server").withCommands(CliCustomNodeRole.class); builder.withGroup("server").withCommands(CliCustomNodeRole.class);
} }

View File

@ -19,7 +19,7 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import io.airlift.airline.Cli.CliBuilder; import com.github.rvesse.airline.builder.CliBuilder;
public class QueryRetryTestCommandCreator implements CliCommandCreator public class QueryRetryTestCommandCreator implements CliCommandCreator
{ {

View File

@ -732,14 +732,18 @@ name: Airline
license_category: binary license_category: binary
module: java-core module: java-core
license_name: Apache License version 2.0 license_name: Apache License version 2.0
version: 0.7 version: 2.8.4
libraries: libraries:
- io.airlift: airline - com.github.rvesse: airline
- com.github.rvesse: airline-io
notices: notices:
- airline: | - airline: |
Copyright Notices Copyright Notices
================= =================
Copyright 2013-18 Rob Vesse <rvesse@dotnetrdf.org>
Copyright 2013 Fernando Hernandez <fernando@clarkparsia.com>
Copyright 2013 Michael Grove <mike@clarkparsia.com>
Copyright 2011 Dain Sundstrom <dain@iq80.com> Copyright 2011 Dain Sundstrom <dain@iq80.com>
Copyright 2010 Cedric Beust <cedric@beust.com> Copyright 2010 Cedric Beust <cedric@beust.com>
@ -1501,6 +1505,16 @@ libraries:
--- ---
name: Jakarta Dependency Injection
license_category: binary
module: java-core
license_name: Apache License version 2.0
version: 1.0.3
libraries:
- jakarta.inject: jakarta.inject-api
---
name: Javax Inject name: Javax Inject
license_category: binary license_category: binary
module: java-core module: java-core

17
pom.xml
View File

@ -277,16 +277,9 @@
<version>1.0.4</version> <version>1.0.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.airlift</groupId> <groupId>com.github.rvesse</groupId>
<artifactId>airline</artifactId> <artifactId>airline</artifactId>
<version>0.7</version> <version>2.8.4</version>
<exclusions>
<exclusion>
<!--LGPL licenced library-->
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.skife.config</groupId> <groupId>org.skife.config</groupId>
@ -471,9 +464,9 @@
<version>1.1.0.Final</version> <version>1.1.0.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.inject</groupId> <groupId>jakarta.inject</groupId>
<artifactId>javax.inject</artifactId> <artifactId>jakarta.inject-api</artifactId>
<version>1</version> <version>1.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.el</groupId> <groupId>javax.el</groupId>

View File

@ -145,12 +145,12 @@
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.inject</groupId> <groupId>jakarta.inject</groupId>
<artifactId>guice</artifactId> <artifactId>jakarta.inject-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.inject</groupId> <groupId>com.google.inject</groupId>
<artifactId>javax.inject</artifactId> <artifactId>guice</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>

View File

@ -67,8 +67,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.inject</groupId> <groupId>jakarta.inject</groupId>
<artifactId>javax.inject</artifactId> <artifactId>jakarta.inject-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.zookeeper</groupId> <groupId>org.apache.zookeeper</groupId>

View File

@ -32,7 +32,7 @@
<dependencies> <dependencies>
<!-- include druid-core to prevent older versions of dependencies <!-- include druid-core to prevent older versions of dependencies
from being pulled in by airline and dependencies of druid-server --> from being pulled in by dependencies of druid-server -->
<dependency> <dependency>
<groupId>org.apache.druid</groupId> <groupId>org.apache.druid</groupId>
<artifactId>druid-core</artifactId> <artifactId>druid-core</artifactId>
@ -70,7 +70,7 @@
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.airlift</groupId> <groupId>com.github.rvesse</groupId>
<artifactId>airline</artifactId> <artifactId>airline</artifactId>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -19,13 +19,13 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Command;
import org.apache.druid.client.BrokerInternalQueryConfig; import org.apache.druid.client.BrokerInternalQueryConfig;
import org.apache.druid.client.BrokerSegmentWatcherConfig; import org.apache.druid.client.BrokerSegmentWatcherConfig;
import org.apache.druid.client.BrokerServerView; import org.apache.druid.client.BrokerServerView;

View File

@ -21,6 +21,7 @@ package org.apache.druid.cli;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rvesse.airline.annotations.Command;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -33,7 +34,6 @@ import com.google.inject.Provider;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import com.google.inject.util.Providers; import com.google.inject.util.Providers;
import io.airlift.airline.Command;
import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFramework;
import org.apache.druid.audit.AuditManager; import org.apache.druid.audit.AuditManager;
import org.apache.druid.client.CoordinatorSegmentWatcherConfig; import org.apache.druid.client.CoordinatorSegmentWatcherConfig;

View File

@ -19,11 +19,12 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Arguments;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.restrictions.Required;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.airlift.airline.Arguments;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.druid.guice.ExtensionsConfig; import org.apache.druid.guice.ExtensionsConfig;
import org.apache.druid.indexing.common.config.TaskConfig; import org.apache.druid.indexing.common.config.TaskConfig;
import org.apache.druid.initialization.Initialization; import org.apache.druid.initialization.Initialization;
@ -50,16 +51,17 @@ public class CliHadoopIndexer implements Runnable
private static final Logger log = new Logger(CliHadoopIndexer.class); private static final Logger log = new Logger(CliHadoopIndexer.class);
@Arguments(description = "A JSON object or the path to a file that contains a JSON object", required = true) @Arguments(description = "A JSON object or the path to a file that contains a JSON object")
@Required
private String argumentSpec; private String argumentSpec;
@Option(name = {"-c", "--coordinate", "hadoopDependencies"}, @Option(name = {"-c", "--coordinate", "hadoopDependencies"},
description = "extra dependencies to pull down (e.g. non-default hadoop coordinates or extra hadoop jars)") description = "extra dependencies to pull down (e.g. non-default hadoop coordinates or extra hadoop jars)")
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private List<String> coordinates; private List<String> coordinates;
@Option(name = "--no-default-hadoop", @Option(name = "--no-default-hadoop",
description = "don't pull down the default hadoop version", description = "don't pull down the default hadoop version")
required = false)
public boolean noDefaultHadoop; public boolean noDefaultHadoop;
@Inject @Inject

View File

@ -19,6 +19,7 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -27,7 +28,6 @@ import com.google.inject.Inject;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Command;
import org.apache.druid.client.cache.CacheConfig; import org.apache.druid.client.cache.CacheConfig;
import org.apache.druid.curator.ZkEnablementConfig; import org.apache.druid.curator.ZkEnablementConfig;
import org.apache.druid.discovery.NodeRole; import org.apache.druid.discovery.NodeRole;

View File

@ -19,6 +19,7 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Binder; import com.google.inject.Binder;
@ -27,7 +28,6 @@ import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Command;
import org.apache.druid.client.DruidServer; import org.apache.druid.client.DruidServer;
import org.apache.druid.client.DruidServerConfig; import org.apache.druid.client.DruidServerConfig;
import org.apache.druid.curator.ZkEnablementConfig; import org.apache.druid.curator.ZkEnablementConfig;

View File

@ -19,6 +19,9 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Arguments;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.restrictions.Required;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -26,8 +29,6 @@ import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Arguments;
import io.airlift.airline.Command;
import org.apache.druid.guice.LazySingleton; import org.apache.druid.guice.LazySingleton;
import org.apache.druid.indexer.HadoopDruidDetermineConfigurationJob; import org.apache.druid.indexer.HadoopDruidDetermineConfigurationJob;
import org.apache.druid.indexer.HadoopDruidIndexerConfig; import org.apache.druid.indexer.HadoopDruidIndexerConfig;
@ -61,7 +62,8 @@ public class CliInternalHadoopIndexer extends GuiceRunnable
{ {
private static final Logger log = new Logger(CliHadoopIndexer.class); private static final Logger log = new Logger(CliHadoopIndexer.class);
@Arguments(description = "A JSON object or the path to a file that contains a JSON object", required = true) @Arguments(description = "A JSON object or the path to a file that contains a JSON object")
@Required
private String argumentSpec; private String argumentSpec;
private HadoopDruidIndexerConfig config; private HadoopDruidIndexerConfig config;

View File

@ -19,6 +19,7 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Binder; import com.google.inject.Binder;
@ -30,7 +31,6 @@ import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.MapBinder; import com.google.inject.multibindings.MapBinder;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import com.google.inject.util.Providers; import com.google.inject.util.Providers;
import io.airlift.airline.Command;
import org.apache.druid.client.indexing.HttpIndexingServiceClient; import org.apache.druid.client.indexing.HttpIndexingServiceClient;
import org.apache.druid.client.indexing.IndexingServiceClient; import org.apache.druid.client.indexing.IndexingServiceClient;
import org.apache.druid.curator.ZkEnablementConfig; import org.apache.druid.curator.ZkEnablementConfig;

View File

@ -20,6 +20,7 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rvesse.airline.annotations.Command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Binder; import com.google.inject.Binder;
@ -33,7 +34,6 @@ import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import com.google.inject.servlet.GuiceFilter; import com.google.inject.servlet.GuiceFilter;
import com.google.inject.util.Providers; import com.google.inject.util.Providers;
import io.airlift.airline.Command;
import org.apache.druid.audit.AuditManager; import org.apache.druid.audit.AuditManager;
import org.apache.druid.client.indexing.HttpIndexingServiceClient; import org.apache.druid.client.indexing.HttpIndexingServiceClient;
import org.apache.druid.client.indexing.IndexingService; import org.apache.druid.client.indexing.IndexingService;

View File

@ -20,6 +20,10 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rvesse.airline.annotations.Arguments;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.restrictions.Required;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.inject.Binder; import com.google.inject.Binder;
@ -33,9 +37,6 @@ import com.google.inject.multibindings.MapBinder;
import com.google.inject.multibindings.Multibinder; import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Named; import com.google.inject.name.Named;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Arguments;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.netty.util.SuppressForbidden; import io.netty.util.SuppressForbidden;
import org.apache.druid.client.cache.CacheConfig; import org.apache.druid.client.cache.CacheConfig;
import org.apache.druid.client.coordinator.CoordinatorClient; import org.apache.druid.client.coordinator.CoordinatorClient;
@ -143,7 +144,8 @@ import java.util.Set;
public class CliPeon extends GuiceRunnable public class CliPeon extends GuiceRunnable
{ {
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
@Arguments(description = "task.json status.json report.json", required = true) @Arguments(description = "task.json status.json report.json")
@Required
public List<String> taskAndStatusFile; public List<String> taskAndStatusFile;
// path to store the task's stdout log // path to store the task's stdout log

View File

@ -19,13 +19,13 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Command;
import org.apache.druid.curator.discovery.DiscoveryModule; import org.apache.druid.curator.discovery.DiscoveryModule;
import org.apache.druid.discovery.NodeRole; import org.apache.druid.discovery.NodeRole;
import org.apache.druid.guice.Jerseys; import org.apache.druid.guice.Jerseys;

View File

@ -19,12 +19,13 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.restrictions.Required;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.druid.guice.DruidProcessingModule; import org.apache.druid.guice.DruidProcessingModule;
import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.JsonConfigProvider;
import org.apache.druid.guice.QueryRunnerFactoryModule; import org.apache.druid.guice.QueryRunnerFactoryModule;
@ -44,13 +45,16 @@ import java.util.List;
) )
public class CreateTables extends GuiceRunnable public class CreateTables extends GuiceRunnable
{ {
@Option(name = "--connectURI", description = "Database JDBC connection string", required = true) @Option(name = "--connectURI", description = "Database JDBC connection string")
@Required
private String connectURI; private String connectURI;
@Option(name = "--user", description = "Database username", required = true) @Option(name = "--user", description = "Database username")
@Required
private String user; private String user;
@Option(name = "--password", description = "Database password", required = true) @Option(name = "--password", description = "Database password")
@Required
private String password; private String password;
@Option(name = "--base", description = "Base table name") @Option(name = "--base", description = "Base table name")

View File

@ -21,6 +21,9 @@ package org.apache.druid.cli;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.restrictions.Required;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -32,8 +35,6 @@ import com.google.inject.Injector;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.netty.util.SuppressForbidden; import io.netty.util.SuppressForbidden;
import org.apache.druid.collections.bitmap.BitmapFactory; import org.apache.druid.collections.bitmap.BitmapFactory;
import org.apache.druid.collections.bitmap.ConciseBitmapFactory; import org.apache.druid.collections.bitmap.ConciseBitmapFactory;
@ -120,48 +121,42 @@ public class DumpSegment extends GuiceRunnable
@Option( @Option(
name = {"-d", "--directory"}, name = {"-d", "--directory"},
title = "directory", title = "directory",
description = "Directory containing segment data.", description = "Directory containing segment data.")
required = true) @Required
public String directory; public String directory;
@Option( @Option(
name = {"-o", "--out"}, name = {"-o", "--out"},
title = "file", title = "file",
description = "File to write to, or omit to write to stdout.", description = "File to write to, or omit to write to stdout.")
required = false)
public String outputFileName; public String outputFileName;
@Option( @Option(
name = {"--filter"}, name = {"--filter"},
title = "json", title = "json",
description = "Filter, JSON encoded, or omit to include all rows. Only used if dumping rows.", description = "Filter, JSON encoded, or omit to include all rows. Only used if dumping rows.")
required = false)
public String filterJson = null; public String filterJson = null;
@Option( @Option(
name = {"-c", "--column"}, name = {"-c", "--column"},
title = "column", title = "column",
description = "Column to include, specify multiple times for multiple columns, or omit to include all columns.", description = "Column to include, specify multiple times for multiple columns, or omit to include all columns.")
required = false)
public List<String> columnNamesFromCli = new ArrayList<>(); public List<String> columnNamesFromCli = new ArrayList<>();
@Option( @Option(
name = "--time-iso8601", name = "--time-iso8601",
title = "Format __time column in ISO8601 format rather than long. Only used if dumping rows.", title = "Format __time column in ISO8601 format rather than long. Only used if dumping rows.")
required = false)
public boolean timeISO8601 = false; public boolean timeISO8601 = false;
@Option( @Option(
name = "--dump", name = "--dump",
title = "type", title = "type",
description = "Dump either 'rows' (default), 'metadata', or 'bitmaps'", description = "Dump either 'rows' (default), 'metadata', or 'bitmaps'")
required = false)
public String dumpTypeString = DumpType.ROWS.toString(); public String dumpTypeString = DumpType.ROWS.toString();
@Option( @Option(
name = "--decompress-bitmaps", name = "--decompress-bitmaps",
title = "Dump bitmaps as arrays rather than base64-encoded compressed bitmaps. Only used if dumping bitmaps.", title = "Dump bitmaps as arrays rather than base64-encoded compressed bitmaps. Only used if dumping bitmaps.")
required = false)
public boolean decompressBitmaps = false; public boolean decompressBitmaps = false;
@Override @Override

View File

@ -21,14 +21,15 @@ package org.apache.druid.cli;
import com.fasterxml.jackson.databind.InjectableValues; import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.restrictions.Required;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import com.opencsv.CSVParser; import com.opencsv.CSVParser;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.druid.guice.DruidProcessingModule; import org.apache.druid.guice.DruidProcessingModule;
import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.JsonConfigProvider;
import org.apache.druid.guice.QueryRunnerFactoryModule; import org.apache.druid.guice.QueryRunnerFactoryModule;
@ -64,7 +65,8 @@ import java.util.UUID;
) )
public class ExportMetadata extends GuiceRunnable public class ExportMetadata extends GuiceRunnable
{ {
@Option(name = "--connectURI", description = "Database JDBC connection string", required = true) @Option(name = "--connectURI", description = "Database JDBC connection string")
@Required
private String connectURI; private String connectURI;
@Option(name = "--user", description = "Database username") @Option(name = "--user", description = "Database username")
@ -79,50 +81,43 @@ public class ExportMetadata extends GuiceRunnable
@Option( @Option(
name = {"-b", "--s3bucket"}, name = {"-b", "--s3bucket"},
title = "s3bucket", title = "s3bucket",
description = "S3 bucket of the migrated segments", description = "S3 bucket of the migrated segments")
required = false)
public String s3Bucket = null; public String s3Bucket = null;
@Option( @Option(
name = {"-k", "--s3baseKey"}, name = {"-k", "--s3baseKey"},
title = "s3baseKey", title = "s3baseKey",
description = "S3 baseKey of the migrated segments", description = "S3 baseKey of the migrated segments")
required = false)
public String s3baseKey = null; public String s3baseKey = null;
@Option( @Option(
name = {"-h", "--hadoopStorageDirectory"}, name = {"-h", "--hadoopStorageDirectory"},
title = "hadoopStorageDirectory", title = "hadoopStorageDirectory",
description = "hadoopStorageDirectory of the migrated segments", description = "hadoopStorageDirectory of the migrated segments")
required = false)
public String hadoopStorageDirectory = null; public String hadoopStorageDirectory = null;
@Option( @Option(
name = {"-n", "--newLocalPath"}, name = {"-n", "--newLocalPath"},
title = "newLocalPath", title = "newLocalPath",
description = "newLocalPath of the migrated segments", description = "newLocalPath of the migrated segments")
required = false)
public String newLocalPath = null; public String newLocalPath = null;
@Option( @Option(
name = {"-o", "--output-path"}, name = {"-o", "--output-path"},
title = "output-path", title = "output-path",
description = "CSV output path", description = "CSV output path")
required = false)
public String outputPath = null; public String outputPath = null;
@Option( @Option(
name = {"-x", "--use-hex-blobs"}, name = {"-x", "--use-hex-blobs"},
title = "use-hex-blobs", title = "use-hex-blobs",
description = "Write BLOB payloads as hex strings", description = "Write BLOB payloads as hex strings")
required = false)
public boolean useHexBlobs = false; public boolean useHexBlobs = false;
@Option( @Option(
name = {"-t", "--booleans-as-strings"}, name = {"-t", "--booleans-as-strings"},
title = "booleans-as-strings", title = "booleans-as-strings",
description = "Write boolean values as true/false strings instead of 1/0", description = "Write boolean values as true/false strings instead of 1/0")
required = false)
public boolean booleansAsStrings = false; public boolean booleansAsStrings = false;
private static final Logger log = new Logger(ExportMetadata.class); private static final Logger log = new Logger(ExportMetadata.class);

View File

@ -19,10 +19,11 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.Cli;
import com.github.rvesse.airline.builder.CliBuilder;
import com.github.rvesse.airline.help.Help;
import com.github.rvesse.airline.parser.errors.ParseException;
import com.google.inject.Injector; import com.google.inject.Injector;
import io.airlift.airline.Cli;
import io.airlift.airline.Help;
import io.airlift.airline.ParseException;
import io.netty.util.SuppressForbidden; import io.netty.util.SuppressForbidden;
import org.apache.druid.cli.validate.DruidJsonValidator; import org.apache.druid.cli.validate.DruidJsonValidator;
import org.apache.druid.guice.ExtensionsConfig; import org.apache.druid.guice.ExtensionsConfig;
@ -49,7 +50,7 @@ public class Main
@SuppressForbidden(reason = "System#out") @SuppressForbidden(reason = "System#out")
public static void main(String[] args) public static void main(String[] args)
{ {
final Cli.CliBuilder<Runnable> builder = Cli.builder("druid"); final CliBuilder<Runnable> builder = Cli.builder("druid");
builder.withDescription("Druid command-line runner.") builder.withDescription("Druid command-line runner.")
.withDefaultCommand(Help.class) .withDefaultCommand(Help.class)

View File

@ -19,14 +19,14 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.netty.util.SuppressForbidden; import io.netty.util.SuppressForbidden;
import io.tesla.aether.Repository; import io.tesla.aether.Repository;
import io.tesla.aether.TeslaAether; import io.tesla.aether.TeslaAether;
@ -253,7 +253,7 @@ public class PullDependencies implements Runnable
) )
public String proxyPassword = ""; public String proxyPassword = "";
@SuppressWarnings("unused") // used by io.airlift:airline @SuppressWarnings("unused") // used by com.github.rvesse.airline
public PullDependencies() public PullDependencies()
{ {
hadoopExclusions = Dependencies.builder() hadoopExclusions = Dependencies.builder()

View File

@ -19,12 +19,12 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.druid.guice.DruidProcessingModule; import org.apache.druid.guice.DruidProcessingModule;
import org.apache.druid.guice.IndexingServiceTaskLogsModule; import org.apache.druid.guice.IndexingServiceTaskLogsModule;
import org.apache.druid.guice.JsonConfigProvider; import org.apache.druid.guice.JsonConfigProvider;

View File

@ -19,13 +19,14 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import com.github.rvesse.airline.annotations.Arguments;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.restrictions.Required;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.inject.Binder; import com.google.inject.Binder;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Arguments;
import io.airlift.airline.Command;
import org.apache.druid.guice.DruidProcessingModule; import org.apache.druid.guice.DruidProcessingModule;
import org.apache.druid.guice.QueryRunnerFactoryModule; import org.apache.druid.guice.QueryRunnerFactoryModule;
import org.apache.druid.guice.QueryableModule; import org.apache.druid.guice.QueryableModule;
@ -51,9 +52,8 @@ public class ValidateSegments extends GuiceRunnable
super(log); super(log);
} }
@Arguments( @Arguments(description = "Two directories where each directory contains segment files to validate.")
description = "Two directories where each directory contains segment files to validate.", @Required
required = true)
public List<String> directories; public List<String> directories;
@Override @Override

View File

@ -19,7 +19,7 @@
package org.apache.druid.cli; package org.apache.druid.cli;
import io.airlift.airline.Command; import com.github.rvesse.airline.annotations.Command;
import io.netty.util.SuppressForbidden; import io.netty.util.SuppressForbidden;
import org.apache.druid.initialization.DruidModule; import org.apache.druid.initialization.DruidModule;
import org.apache.druid.initialization.Initialization; import org.apache.druid.initialization.Initialization;

View File

@ -21,6 +21,9 @@ package org.apache.druid.cli.validate;
import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.restrictions.Required;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -30,8 +33,6 @@ import com.google.common.io.LineProcessor;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.netty.util.SuppressForbidden; import io.netty.util.SuppressForbidden;
import org.apache.commons.io.output.NullWriter; import org.apache.commons.io.output.NullWriter;
import org.apache.druid.cli.GuiceRunnable; import org.apache.druid.cli.GuiceRunnable;
@ -76,16 +77,18 @@ public class DruidJsonValidator extends GuiceRunnable
private static final Logger LOG = new Logger(DruidJsonValidator.class); private static final Logger LOG = new Logger(DruidJsonValidator.class);
private Writer logWriter = new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8)); private Writer logWriter = new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8));
@Option(name = "-f", title = "file", description = "file to validate", required = true) @Option(name = "-f", title = "file", description = "file to validate")
@Required
public String jsonFile; public String jsonFile;
@Option(name = "-t", title = "type", description = "the type of schema to validate", required = true) @Option(name = "-t", title = "type", description = "the type of schema to validate")
@Required
public String type; public String type;
@Option(name = "-r", title = "resource", description = "optional resources required for validation", required = false) @Option(name = "-r", title = "resource", description = "optional resources required for validation")
public String resource; public String resource;
@Option(name = "--log", title = "toLogger", description = "redirects any outputs to logger", required = false) @Option(name = "--log", title = "toLogger", description = "redirects any outputs to logger")
public boolean toLogger; public boolean toLogger;
public DruidJsonValidator() public DruidJsonValidator()

View File

@ -0,0 +1,31 @@
/*
* 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.druid.cli;
import org.junit.Test;
public class CliMainTest
{
@Test
public void testHelp()
{
Main.main(new String[]{"help"});
}
}

View File

@ -21,8 +21,8 @@ package org.apache.druid.cli.validate;
import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.rvesse.airline.Cli;
import com.google.inject.Injector; import com.google.inject.Injector;
import io.airlift.airline.Cli;
import org.apache.druid.guice.FirehoseModule; import org.apache.druid.guice.FirehoseModule;
import org.apache.druid.guice.GuiceInjectors; import org.apache.druid.guice.GuiceInjectors;
import org.apache.druid.indexing.common.task.RealtimeIndexTask; import org.apache.druid.indexing.common.task.RealtimeIndexTask;

View File

@ -113,6 +113,10 @@
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
</dependency> </dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.google.inject</groupId> <groupId>com.google.inject</groupId>
<artifactId>guice</artifactId> <artifactId>guice</artifactId>
@ -133,10 +137,6 @@
<groupId>com.google.inject.extensions</groupId> <groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId> <artifactId>guice-multibindings</artifactId>
</dependency> </dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency> <dependency>
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId> <artifactId>jsr311-api</artifactId>